1.首先新建一个文件夹例如:Home,而后在该文件中新建两个文件Home.vue和index.jsvue
2.在Home.vue中和往常同样如:app
<template> <div id="Home"> <h1>加上点加鸡蛋</h1> </div> </template> <script> export default{ name:"Home" } </script>
3.接下来是index.js的编写(主要)code
import Home from './Home.vue' // install方法必须有 export default{ install:function(Vue) { Vue.component('Home',Home); } }
4.接下来就能够在main.js中美美的引入你的组件了component
import Home from './components/Home' Vue.use(Home)
5.使用(在App.vue中)ip
<div id="app"> <mt-button type="default">default</mt-button> <mt-button type="primary">primary</mt-button> <mt-button type="danger">danger</mt-button> <Home></Home> </div>
6.效果展现get