mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
docs(Overlay): use composition api
This commit is contained in:
parent
488deefb30
commit
8a2495ee6b
@ -20,13 +20,14 @@ app.use(Overlay);
|
||||
```
|
||||
|
||||
```js
|
||||
import { ref } from 'vue';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
show: false
|
||||
}
|
||||
}
|
||||
},
|
||||
setup() {
|
||||
const show = ref(false);
|
||||
return { show };
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### Embedded Content
|
||||
|
@ -24,13 +24,14 @@ app.use(Overlay);
|
||||
```
|
||||
|
||||
```js
|
||||
import { ref } from 'vue';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
show: false
|
||||
}
|
||||
}
|
||||
},
|
||||
setup() {
|
||||
const show = ref(false);
|
||||
return { show };
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### 嵌入内容
|
||||
|
@ -3,7 +3,7 @@
|
||||
<van-button
|
||||
type="primary"
|
||||
:text="t('showOverlay')"
|
||||
style="margin-left: 16px;"
|
||||
style="margin-left: 16px"
|
||||
@click="show = true"
|
||||
/>
|
||||
<van-overlay :show="show" @click="show = false" />
|
||||
@ -13,7 +13,7 @@
|
||||
<van-button
|
||||
type="primary"
|
||||
:text="t('embeddedContent')"
|
||||
style="margin-left: 16px;"
|
||||
style="margin-left: 16px"
|
||||
@click="showEmbedded = true"
|
||||
/>
|
||||
<van-overlay :show="showEmbedded" @click="showEmbedded = false">
|
||||
@ -25,6 +25,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { reactive, toRefs } from 'vue';
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
@ -37,11 +39,13 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
show: false,
|
||||
showEmbedded: false,
|
||||
};
|
||||
});
|
||||
|
||||
return toRefs(state);
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user