1.在src文件夹中创建一个hello文件夹,然后创建hello.js和hello.vue

2.hello.vue代码如下

 <template>
<button>这是hello按钮</button>
</template> <script>
export default { }
</script> <style>
button {
width: 200px;
height: 50px;
background-color: pink;
border-radius: 20px;
}
</style>

3.hello.js代码如下

// 导入我们刚刚写的hello.vue文件
import HelloComponent from './hello.vue' const hello = {
// 将来这个 hello插件,被vue.use时,会自动调用内部的install方法,进行一些全局组件的注册
install: function (Vue) {
Vue.component('hello', HelloComponent)
}
}
// 导出
export default hello

4.在App.vue中直接使用

<template>
<div id="app">
//hello组件
<hello></hello>
</div>
</template> <style lang="less">
</style>

5.在main.js文件中引入,代码如下

import Vue from 'vue'
import App from './App.vue'
import store from './store'
// 引入
import hello from './hello/hello.js' Vue.config.productionTip = false // 进行一些全局组件的注册,以及一些其他的全局初始化
Vue.use(hello) new Vue({
render: h => h(App),
// 挂载vuex
store
}).$mount('#app')

5.一个简单的vue组件就写好了,看一下运行效果

最新文章

  1. Linux 查找进程运行位置
  2. Weblogic新增域(可以配置新端口)
  3. 【uTenux实验】集合点端口
  4. Kooboo中怎么写Page Plugin -摘自官方文档
  5. 1003: A Bug
  6. HttpClient---------demo
  7. 富文本NSAttributeString
  8. 数据库之redis篇(2)—— redis配置文件,常用命令,性能测试工具
  9. 微信小程序中的app.js-清除缓存
  10. PowerDesigner 12.5 汉化包-CSDN下载
  11. 小程序https请求,http网站升到https
  12. 什么是less?
  13. 截断文件函数truncate和ftruncate
  14. linux配置虚拟主机
  15. js jquery 取得周月年时间
  16. C# 利用反射将枚举绑定到下拉框
  17. C# winform开发嵌套Chrome内核浏览器(WebKit.net)开发(一)
  18. Shiro的使用
  19. [OI向?] ubuntu下一些常用的技巧
  20. TransactionScope 的基本原理简介

热门文章

  1. 总结一下 IEnumerable 的例子
  2. 我的第一个 60 k+ Star Java开源项目
  3. nyoj 36-最长公共子序列 (动态规划,DP, LCS)
  4. Bootstrap——面包屑导航(Breadcrumbs)
  5. 【SpringBoot | Redis】SpringBoot整合Redis
  6. 力扣(LeetCode)查找常用字符 个人题解
  7. tomcat-9.0.20缓存空间不足
  8. HTTP 协议漫谈
  9. Golang 入门系列(十六)锁的使用场景主要涉及到哪些?读写锁为什么会比普通锁快
  10. Spring Security框架下实现两周内自动登录&quot;记住我&quot;功能