博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vue2.0 vue-loader
阅读量:6599 次
发布时间:2019-06-24

本文共 3371 字,大约阅读时间需要 11 分钟。

vue-clinpm 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

      
vue-demo

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

New.vue

Home.vue

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 
", "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" }}

 

转载地址:http://fvlio.baihongyu.com/

你可能感兴趣的文章
顶级的JavaScript框架、库、工具及其使用
查看>>
分享Kali Linux 2016.2第49周镜像文件
查看>>
AYUI -AYUI风格的 超美 百度网盘8.0
查看>>
linux下php中文UTF-8转换Unicode方法和注意事项
查看>>
TensorFlow:tf.contrib.layers.xavier_initializer
查看>>
快开学了,又被逼死一个!!现教育部已经成为催命阎王!!, 转自中华网
查看>>
简明 Python 教程
查看>>
Photoshop操作指南
查看>>
用MPMoviePlayerController做在线音乐播放
查看>>
ASP.NET调用cmd命令提示符拒绝访问解决方案
查看>>
Leetcode: Construct Binary Tree from Preorder and Inorder Transversal
查看>>
嵌入式开发之字符叠加---gb2313 国标码,utf8 国际码,unicode 无码
查看>>
Java查找算法——二分查找
查看>>
数据在千万级别上进行全文检索有哪些技术?强大的大数据全文索引解决方案-ClouderaSearch...
查看>>
E. Dreamoon and Strings(Codeforces Round #272)
查看>>
android --多线程下载
查看>>
利用Arduino快速制作Teensy BadUSB, 攻击计算机
查看>>
初始加载时edittext不自动获取焦点的方法
查看>>
Skipping Windows Azure Startup Tasks When Running in the Emulator
查看>>
C实现计算任意整数不损失精度的阶乘
查看>>