vue学习笔记三

vue学习笔记三

vue学习笔记一 

vue学习笔记二


才发现写了两篇一直是webpack的东西。今天用点vue的组件:

根目录下新建一个template文件夹, 顾名思义,是用来放vue组件的

在template新建一个hello.vue



hello.vue里面写点东西,顺便加点样式

<template lang="html">
  <div id="hello">
    {{message}},{{name}}
  </div>
</template>
<script>
export default {
  name:"hello",
  data(){
    return {
        message:"hello",
        name:"world"
    }
  }
}
</script>
<style lang="css">
  #hello{
    font-size:14px;
    color:#ff0202
  }
</style>

修改src/js/index.js文件




引入我们刚刚写的.vue模板

import helloVue from './../../template/hello.vue' ;


之前的data数据我们现在可以不要了,  删掉后注册引入的组件

new Vue({
el: "#app" ,
components: { "helloVue" : helloVue }
})


修改根目录的index.html文件;


<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< meta http-equiv = "X-UA-Compatible" content = "ie=edge" >
< title >vue_study</ title >
</ head >
< body >
< div id = "app" >
< hello-vue ></ hello-vue >
</ div >
</ body >
</ html >

只留刚刚的注册的那个组件


安装 vue-loader 模块;


然后我们需要修改webpack.config.js;

添加vue的解析:

{
test: / \. vue $ / ,
use: [ 'vue-loader' ]
},

到这里基本上已经完成了。


执行打包:

webpack


如果没有意外的话,刷新页面应该是这样的





到这里一个基本的.vue打包已经完成了。

下次我们写个dotolist


我也是一个vue新人,有什么不对的地方欢迎大家指正交流





  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值