Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

539
Visualizações
How to apply component in antdesign with vue-cli and vue 3?

I already follow the instruction on the docs here.

This is what I did

vue create example-app
cd example-app

I choose the vue 3 preset.

then change the script in main.js

import Vue from 'vue';
import Button from 'ant-design-vue/lib/button';
import 'ant-design-vue/dist/antd.css';
import App from './App';

Vue.component(Button.name, Button);

Vue.config.productionTip = false;

new Vue({
  render: h => h(App),
}).$mount('#app');

here's my App.js file

<template>
  <div id="app">
    <img src="./assets/logo.png">
    <a-button type="primary">Button</a-button>
  </div>
</template>

<script>

export default {
  name: 'App',
  components: {
  }
}
</script>

<style>

</style>

But why there is no Button component on the screen? all I got is blank screen

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

I've failed to reproduce what's mentioned here. the code works perfectly. I think probably there's something left out from your writing.

here's the working code. try compare this with yours.

https://codesandbox.io/s/cocky-leftpad-hbi3i?file=/src/App.vue


For Vue 3, things are still pretty much the same. Vue 3 uses different plugin install method.

// main.js
import { createApp } from 'vue'
import App from './App.vue'
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';

const app = createApp(App)

app.use(Antd) // same as Vue.use in Vue 2.X
app.mount('#app')

this code isn't mine but it shows the same thing.

https://codesandbox.io/s/vue3-antd-xzk1x?file=/src/main.js

over 4 years ago · Santiago Trujillo Relatório

0

enter image description here

I just ran the project and this is the displayed result.

Steps I followed.

  1. npm install -g @vue/cli
  2. vue create antd-demo
  3. I selected the vue2 preset
  4. cd antd-demo
  5. npm install ant-design-vue
  6. modified src/main.js (as per docs)
  7. modified src/App.vue (as per docs)
  8. npm run serve
over 4 years ago · Santiago Trujillo Relatório

0

In my case, my fault was that I chose vue3 and followed instructions in https://antdv.com/docs/vue/getting-started/, but had to follow https://2x.antdv.com/docs/vue/getting-started

npm i --save ant-design-vue@next

(@next !)

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda