docs(Skeleton): use composition api

This commit is contained in:
chenjiahan 2020-12-13 12:51:02 +08:00
parent 71d5a27dc4
commit f93e21a099
3 changed files with 45 additions and 28 deletions

View File

@ -33,15 +33,20 @@ app.use(Skeleton);
``` ```
```js ```js
import { ref, onMounted } from 'vue';
export default { export default {
data() { setup() {
const loading = ref(true);
onMounted(() => {
loading.value = false;
});
return { return {
loading: true, loading,
}; };
}, },
mounted() {
this.loading = false;
},
}; };
``` ```

View File

@ -43,15 +43,20 @@ app.use(Skeleton);
``` ```
```js ```js
import { ref, onMounted } from 'vue';
export default { export default {
data() { setup() {
const loading = ref(true);
onMounted(() => {
loading.value = false;
});
return { return {
loading: true, loading,
}; };
}, },
mounted() {
this.loading = false;
},
}; };
``` ```

View File

@ -22,8 +22,10 @@
</template> </template>
<script> <script>
export default { import { ref } from 'vue';
i18n: { import { useTranslate } from '@demo/use-translate';
const i18n = {
'zh-CN': { 'zh-CN': {
showAvatar: '显示头像', showAvatar: '显示头像',
showChildren: '显示子组件', showChildren: '显示子组件',
@ -37,11 +39,16 @@ export default {
title: 'About Vant', title: 'About Vant',
desc: 'Vant is a set of Mobile UI Components built on Vue.', desc: 'Vant is a set of Mobile UI Components built on Vue.',
}, },
}, };
export default {
setup() {
const t = useTranslate(i18n);
const show = ref(false);
data() {
return { return {
show: false, t,
show,
}; };
}, },
}; };