vue学习笔记三
2017-05-02 09:22
197 查看
vue学习笔记三
vue学习笔记一
vue学习笔记二
才发现写了两篇一直是webpack的东西。今天用点vue的组件:
根目录下新建一个template文件夹, 顾名思义,是用来放vue组件的
在template新建一个hello.vue
hello.vue里面写点东西,顺便加点样式
修改src/js/index.js文件
引入我们刚刚写的.vue模板
importhelloVuefrom'./../../template/hello.vue';
之前的data数据我们现在可以不要了, 删掉后注册引入的组件
new Vue({
el:"#app",
components: {"helloVue":helloVue}
})
修改根目录的index.html文件;
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metaname="viewport"content="width=device-width,
initial-scale=1.0">
<metahttp-equiv="X-UA-Compatible"content="ie=edge">
<title>vue_study</title>
</head>
<body>
<divid="app">
<hello-vue></hello-vue>
</div>
</body>
</html>
只留刚刚的注册的那个组件
安装 vue-loader 模块;
然后我们需要修改webpack.config.js;
添加vue的解析:
{
test:/\.vue$/,
use: ['vue-loader']
},
到这里基本上已经完成了。
执行打包:
webpack
如果没有意外的话,刷新页面应该是这样的
到这里一个基本的.vue打包已经完成了。
下次我们写个dotolist
我也是一个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模板
importhelloVuefrom'./../../template/hello.vue';
之前的data数据我们现在可以不要了, 删掉后注册引入的组件
new Vue({
el:"#app",
components: {"helloVue":helloVue}
})
修改根目录的index.html文件;
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<metaname="viewport"content="width=device-width,
initial-scale=1.0">
<metahttp-equiv="X-UA-Compatible"content="ie=edge">
<title>vue_study</title>
</head>
<body>
<divid="app">
<hello-vue></hello-vue>
</div>
</body>
</html>
只留刚刚的注册的那个组件
安装 vue-loader 模块;
然后我们需要修改webpack.config.js;
添加vue的解析:
{
test:/\.vue$/,
use: ['vue-loader']
},
到这里基本上已经完成了。
执行打包:
webpack
如果没有意外的话,刷新页面应该是这样的
到这里一个基本的.vue打包已经完成了。
下次我们写个dotolist
我也是一个vue新人,有什么不对的地方欢迎大家指正交流
相关文章推荐
- Vue webpack项目无法在控制台 devTool下断点调试
- vue+vuex+axio从后台获取数据存入vuex实现组件之间共享数据
- vue2滚动条加载更多数据实现代码
- Vue实现自带的过滤器实例
- Vue系列:通过vue-router如何传递参数示例
- 简单学习vue指令directive
- 实现一个简单的vue无限加载指令方法
- Vue概念及常见命令介绍(1)
- Vue中的v-cloak使用解读
- 如何在 Vue.js 中使用第三方js库
- 详解Vue使用 vue-cli 搭建项目
- Vue常用指令V-model用法
- 基于vue实现多引擎搜索及关键字提示
- vue中渐进过渡效果实现
- Vue监听数组变化源码解析
- 详解vue事件对象、冒泡、阻止默认行为
- Vue实现购物车功能
- 简单实现Vue的observer和watcher
- vue使用watch 观察路由变化,重新获取内容
- 利用vue实现模态框组件