vue-cli
npm install
脚手架: vue-loader
1.0 ->
new Vue({
el: '#app',
components:{App}
})
2.0->
new Vue({
el: '#app',
render: h => h(App)
})
vue2.0
vue-loader和vue-router配合 style-loader css-loader style!css

index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>vue-demo</title>
<!-- <link rel="stylesheet" href="src/assets/css/animate.css"> 就不需要用loader了 -->
</head>
<body>
<div id="app"></div>
<script src="/dist/build.js"></script>
</body>
</html>

main.js

import Vue from 'vue'
import VueRouter from 'vue-router' import App from './App.vue'
import routerConfig from './router.config.js' import './assets/css/animate.css';
import './assets/css/1.css'; Vue.use(VueRouter); const router=new VueRouter(routerConfig); new Vue({
router,
el: '#app',
render: h => h(App)
})

router.config.js

import Home from './components/Home.vue'
import News from './components/News.vue' export default{
routes:[
{path:'/home', component:Home},
{path:'/news', component:News},
{path:'*', redirect:'/home'}
]
}

App.vue

<template>
<div id="app">
{{msg}}
<ul>
<li>
<router-link to="/home">主页</router-link>
<router-link to="/news">新闻</router-link>
</li>
</ul>
<div>
<transition enter-active-class="animated zoomInLeft" leave-active-class="animated zoomOutRight">
<router-view></router-view>
</transition>
</div>
</div>
</template> <script>
export default {
name: 'app',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script> <style>
html,body{ overflow:hidden; }
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
} h1, h2 {
font-weight: normal;
} ul {
list-style-type: none;
padding: 0;
} li {
display: inline-block;
margin: 0 10px;
} a {
color: #42b983;
}
</style>

New.vue

<template>
<div id="news">
<h3>我是新闻页</h3>
<ul>
<li v-for="(val,index) in news">
{{val}}
</li>
</ul>
</div>
</template>
<script>
export default{
name:'news',
data(){
return {
news:['111111','22222222','3333333333','4444444444']
}
}
}
</script>
<style>
li{ border-bottom:1px dashed #dedede; }
</style>

Home.vue

<template>
<h3>我是主页</h3>
</template>

webpack.config.js

var path = require('path')
var webpack = require('webpack') module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue',
options: {
// vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
},
{
test: /\.css$/,
loader: 'style!css' //顺序定死的,否则不能loader Css,
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue'
}
},
devServer: {
historyApiFallback: true,
noInfo: true
},
devtool: '#eval-source-map'
} if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}

package.json

{
"name": "vue-demo",
"description": "A Vue.js project",
"author": "strive <itstrive@sina.com>",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --inline --hot --port 8085",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"vue": "^2.0.1",
"vue-router": "^2.0.1"
},
"devDependencies": {
"animate.css": "^3.5.2",
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-preset-es2015": "^6.0.0",
"cross-env": "^3.0.0",
"css-loader": "^0.25.0",
"file-loader": "^0.9.0",
"style-loader": "^0.13.1",
"vue-loader": "^9.7.0",
"webpack": "^2.1.0-beta.25",
"webpack-dev-server": "^2.1.0-beta.0"
}
}

vue2.0 vue-loader的更多相关文章

  1. vue2.0 vue.set()

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. vue2.0 vue.extend()的拓展

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. Vue2.0 Vue.set的使用

    原文链接: https://blog.csdn.net/qq_30455841/article/details/78666571

  4. VUE2.0学习总结

    摘要: 年后公司项目开始上vue2.0,自己对学习进行了总结,希望对大家有帮助! VUE2.0学习 vue介绍 vue是什么? https://vuefe.cn/guide vue也是一个数据驱动框架 ...

  5. vue1.0和vue2.0的区别(二)

    这篇我们继续之前的vue1.0和vue2.0的区别(一)继续说 四.循环 学过vue的同学应该知道vue1.0是不能添加重复数据的,否则它会报错,想让它重复添加也不是不可以,不过需要定义别的东西 而v ...

  6. Vue2.0总结———vue使用过程常见的一些问题

    Vue目前的的开发模式主要有两种:1.直接页面级的开发,script直接引入Vue2.工程性开发,webpack+loader或者直接使用脚手架工具Vue-cli,里面的文件都配置好了 webpack ...

  7. vue 专题 vue2.0各大前端移动端ui框架组件展示

    Vue 专题 一个数据驱动的组件,为现代化的 Web 界面而生.具有可扩展的数据绑定机制,原生对象即模型,简洁明了的 API 组件化 UI 构建 多个轻量库搭配使用 请访问链接: https://ww ...

  8. vue2.0实践 —— Node + vue 实现移动官网

    简介 使用 Node + vue 对公司的官网进行了一个简单的移动端的实现. 源码 https://github.com/wx1993/node-vue-fabaocn 效果 组件 轮播图(使用 vu ...

  9. 从壹开始前后端分离 [ Vue2.0+.NET Core2.1] 十五 ║Vue基础:JS面向对象&字面量& this字

    缘起 书接上文<从壹开始前后端分离 [ Vue2.0+.NET Core2.1] 十四 ║ VUE 计划书 & 我的前后端开发简史>,昨天咱们说到了以我的经历说明的web开发经历的 ...

  10. 从壹开始前后端分离 [ Vue2.0+.NET Core2.1] 十六 ║Vue基础:ES6初体验 & 模块化编程

    缘起 昨天说到了<从壹开始前后端分离 [ Vue2.0+.NET Core2.1] 十五 ║ Vue前篇:JS对象&字面量&this>,通过总体来看,好像大家对这一块不是很 ...

随机推荐

  1. django 分组统计遇见的问题

    在使用 django 的时候发现了一个坑 例如: In [54]: print(F.objects.all().values("age").annotate(fff=Count(& ...

  2. linux 调试相关命令

    1. tail -f filename 调试时,log输出到文件,但是又想看到即时输出信息 未完待续....

  3. vue中的methods、computed和watch

    1.computed属性: 经过处理返回的数据值,只要源数据没有发生改变,computed函数里面对相应的数据就不会反生改变,相当于缓存在本地;发生改变的时候,computed对应数据的函数才会发生改 ...

  4. 紫书 习题8-11 UVa 1615 (区间选点问题)

    这个点就是贪心策略中的区间选点问题. 把右端点从大到小排序, 左端点从小到大排序. 每次取区间右端点就可以了, 到不能覆盖的时候就ans++, 重新取点 ps:这道题不考虑精度也可以过 要着重复习一下 ...

  5. PKU 2184 Cow Exhibition 01背包

    题意: 有一些牛,每头牛有一个Si值,一个Fi值,选出一些牛,使得max( sum(Si+Fi) ) 并且 sum(Si)>=0, sum(Fi)>=0 思路: 随便选一维做容量(比如Fi ...

  6. HDU 4965 Fast Matrix Calculation 矩阵乘法 乘法结合律

    一种奇葩的写法,纪念一下当时的RE. #include <iostream> #include <cstdio> #include <cstring> #inclu ...

  7. 2019年北航OO第三单元(JML规格任务)总结

    一.JML简介 1.1 JML与契约式设计 说起JML,就不得不提到契约式设计(Design by Contract).这种设计模式的始祖是1986年的Eiffel语言.它是一种限定了软件中每个元素所 ...

  8. 【BZOJ 1257】[CQOI2007]余数之和

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] k%i=k-(k/i)i 则∑k%i = nk-∑(k/i)*i 因为k/i是整除运算. 所以会有某一段连续的i,它们的k/i的值都 ...

  9. 洛谷 P1990 覆盖墙壁

    P1990 覆盖墙壁 题目描述 你有一个长为N宽为2的墙壁,给你两种砖头:一个长2宽1,另一个是L型覆盖3个单元的砖头.如下图: 0 0 0 00 砖头可以旋转,两种砖头可以无限制提供.你的任务是计算 ...

  10. Qt之QImageReader

    简述 QImageReader类为从文件或设备读取图像提供了一个独立的接口. 读取图像最常用的方法是通过构造QImage和QPixmap,或通过调用QImage::load()和QPixmap::lo ...