1.安装vue-cli脚手架
npm i vue-cli -g
2.通过vue-cli创建基本webpack的vue并初始化项目
vue init webpack
cd
npm i
启动项目
npm run dev
3.加入框架vux
npm install vux --save
vux2必须配合vux-loader使用, 请在build/webpack.base.conf.js里参照如下代码进行配置:
const vuxLoader = require('vux-loader')
const webpackConfig = originalConfig // 原来的 module.exports 代码赋值给变量 webpackConfig
module.exports = vuxLoader.merge(webpackConfig, {
plugins: ['vux-ui']
})
4.项目中用到的插件
less,
less-loader,
vux-loader,
vue-jsonp,
vue-scroller
app.vue
直播
搜索
推荐
要闻
游戏
科技
娱乐
体育
首页
推荐
我的
main.js
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import VueScroller from 'vue-scroller'
import { ToastPlugin } from 'vux'
import VueJsonp from 'vue-jsonp'
Vue.config.productionTip = false
Vue.use(ToastPlugin)
Vue.use(VueScroller)
Vue.use(VueJsonp);
/* eslint-disable no-new */
new Vue({
el: '#app',
template: ' ',
components: { App }
})
package.json
{
"name": "news",
"version": "1.0.0",
"description": "sdfds",
"author": "fengwenxin",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"unit": "jest test/unit/specs --coverage",
"test": "npm run unit",
"build": "node build/build.js"
},
"dependencies": {
"vue": "^2.5.2",
"vue-jsonp": "^0.1.7",
"vue-scroller": "^2.2.4",
"vux": "^2.7.3",
"vux-loader": "^1.1.24"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-jest": "^21.0.2",
"babel-loader": "^7.1.1",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"eventsource-polyfill": "^0.9.6",
"express": "^4.14.1",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"jest": "^21.2.0",
"less": "^2.7.3",
"less-loader": "^4.0.5",
"node-notifier": "^5.1.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-loader": "^2.0.8",
"rimraf": "^2.6.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"url-loader": "^0.5.8",
"vue-jest": "^1.0.2",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"vue"
],
"moduleNameMapper": {
"^@/(.*)$": "/src/$1"
},
"transform": {
"^.+\\.js$": "/node_modules/babel-jest",
".*\\.(vue)$": "/node_modules/vue-jest"
},
"setupFiles": [
"/test/unit/setup"
],
"mapCoverage": true,
"coverageDirectory": "/test/unit/coverage",
"collectCoverageFrom": [
"src/**/*.{js,vue}",
"!src/main.js",
"!**/node_modules/**"
]
},
"engines": {
"node": ">= 4.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}