1、 下载node.js。安装完之后win+r打开cmd。输入node –v 看版本号。
2、 安装webpack。 输入npm install webpack –g。 webpack –v看版本号。
3、 输入npm installvue-cli –g。vue –V看版本号。
4、 输入 npm initwebpack test ,test为项目名。其中use ESLint to link your code?写n。
5、 输入cd test 进去项目。
6、 安装项目依赖 npm install
7、 安装路由 npm installvue-router --save
8、 安装axios,npm install axios ,然后 npm install--save axios vue-axios
9、 安装sass,npm install node-sass --save-dev ,
然后 npm installsass-loader --save-dev。
打开webpack.base.config.js在loaders里面加上 module -- rules(vue2.0)
rules: [
{
test:/\.vue$/,
loader:'vue-loader',
options:vueLoaderConfig
},
{
test:/\.js$/,
loader:'babel-loader',
include:[resolve('src'), resolve('test')]
},
{
test:/\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader:'url-loader',
query: {
limit:10000,
name:utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test:/\.scss$/,
loaders:["style", "css", "sass"]
},
{
test:/\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader:'url-loader',
query: {
limit:10000,
name:utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
}
使用:<style
lang="scss" scoped=""type="text/css"></style>
10、输入 npm install --save vuex 。
11、输入npm run dev 运行项目。
二级域名设置:
Config –index.js –
build: { index: path.resolve(__dirname, '../dist/index.html'), assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static', assetsPublicPath: '/share/' productionSourceMap: true, devtool: '#source-map', productionGzip: false, productionGzipExtensions: ['js', 'css'], bundleAnalyzerReport: process.env.npm_config_report }
node module -- connect-history-api-fallback—lib – index,js
rewriteTarget = options.
index||
'/index.html';
logger(
'Rewriting', req.method, req.url,
'to', rewriteTarget);
req.url = rewriteTarget;
next();
这个的代码,当你不作配置的时候,默认重定向到根目录的
/
index.html
上,找到原因了,修改就简单了
// 处理 history API 的回退情况(如果在线上环境中,也需要服务器做相应处理)
app.use(require(
'connect-history-api-fallback')({
index
:
'/m/index.html'
}));