在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

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐