antd ConfigProvider 全局化配置 (vue2 和 vue3)
在vue3中:// main.jsimport { ConfigProvider } from 'ant-design-vue';import { createApp } from 'vue';import App from './App.vue';const app = createApp(App);app.use(ConfigProvider);app.mount('#app');// App
·
在vue3中:
// main.js
import { ConfigProvider } from 'ant-design-vue';
import { createApp } from 'vue';
import App from './App.vue';
const app = createApp(App);
app.use(ConfigProvider);
app.mount('#app');
// App.vue
<template>
<a-config-provider :locale="locale">
<section id="app">
<router-view />
</section>
</a-config-provider>
</template>
<script>
import locale from 'ant-design-vue/lib/locale-provider/zh_CN';
export default {
name: 'App',
setup() {
return { locale };
},
};
</script>
<style lang="scss">
* {
box-sizing: border-box;
}
*::before,
*::after {
box-sizing: border-box;
}
</style>
在vue2中:
// main.js
import { ConfigProvider } from 'ant-design-vue';
import Vue from 'vue';
import App from './App.vue';
Vue.use(ConfigProvider);
new Vue({
render: (h) => h(App),
}).$mount('#app');
// App.vue
<template>
<a-config-provider :locale="locale">
<div id="app">
<router-view />
</div>
</a-config-provider>
</template>
<script>
import locale from 'ant-design-vue/lib/locale-provider/zh_CN';
export default {
name: 'App',
data() {
return {
locale,
};
},
};
</script>
<style lang="scss">
html,
body,
#app {
width: 100%;
height: 100%;
}
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #0e0e0e;
}
</style>
更多推荐
已为社区贡献5条内容
所有评论(0)