Vue 写一个自定义组件componnet

第一个vue组件

在工程目录/src下创建component文件夹,并在component文件夹下创建一个firstComponent.vue。 
这里写图片描述 
在App.vue中使用插件 ( 因为在 index.html 里面定义了div id=”app”所以就以这个组件作为主入口)

第一步,引入 在便签内的第一行写

import firstComponent from './component/firstComponent.vue'
  • 1

第二步,注册 在标签内的data代码块后面加上component:{firstComponent}

这里写图片描述

第三步,使用 在内加上

这里写图片描述

第四步,在浏览器中打开localhost:8080


猜你喜欢

转载自blog.csdn.net/u013452337/article/details/80653548