mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
docs(Sticky): use composition api
This commit is contained in:
parent
d297807f55
commit
a1de44c97a
@ -40,13 +40,9 @@ app.use(Sticky);
|
||||
|
||||
```js
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
container: null,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.container = this.$refs.container;
|
||||
setup() {
|
||||
const container = ref(null);
|
||||
return { container };
|
||||
},
|
||||
};
|
||||
```
|
||||
|
@ -50,13 +50,9 @@ app.use(Sticky);
|
||||
|
||||
```js
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
container: null,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.container = this.$refs.container;
|
||||
setup() {
|
||||
const container = ref(null);
|
||||
return { container };
|
||||
},
|
||||
};
|
||||
```
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<demo-block :title="t('basicUsage')">
|
||||
<van-sticky>
|
||||
<van-button type="primary" style="margin-left: 15px;">
|
||||
<van-button type="primary" style="margin-left: 15px">
|
||||
{{ t('basicUsage') }}
|
||||
</van-button>
|
||||
</van-sticky>
|
||||
@ -9,16 +9,16 @@
|
||||
|
||||
<demo-block :title="t('offsetTop')">
|
||||
<van-sticky :offset-top="50">
|
||||
<van-button type="primary" style="margin-left: 115px;">
|
||||
<van-button type="primary" style="margin-left: 115px">
|
||||
{{ t('offsetTop') }}
|
||||
</van-button>
|
||||
</van-sticky>
|
||||
</demo-block>
|
||||
|
||||
<demo-block v-if="!isWeapp" :title="t('setContainer')">
|
||||
<div ref="container" style="height: 150px; background-color: #fff;">
|
||||
<div ref="container" style="height: 150px; background-color: #fff">
|
||||
<van-sticky :container="container">
|
||||
<van-button type="warning" style="margin-left: 215px;">
|
||||
<van-button type="warning" style="margin-left: 215px">
|
||||
{{ t('setContainer') }}
|
||||
</van-button>
|
||||
</van-sticky>
|
||||
@ -27,6 +27,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from 'vue';
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
@ -39,14 +41,9 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
container: null,
|
||||
};
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.container = this.$refs.container;
|
||||
setup() {
|
||||
const container = ref(null);
|
||||
return { container };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user