在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>

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐