使用HBuilderX创建的项目,模板使用Hello uni-app,vue2版本。
创建成功后先运行一切正常,然后在根目录添加vue.config.js文件进行构建配置,再之后运行也成功,但是所有的uni自身的生命周期例如onLanch onLoad onShow就都不执行了,仅执行vue本身的生命周期例如mounted等,请问是什么原因呢?
疑惑了一天了,如果onLanch无效,那如何取页面传参?
vue.config.js 文件内容
···
const path = require('path')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const webpack = require("webpack")
module.exports = {
assetsDir: 'static',
productionSourceMap: false,
devServer: {
port:1233,
proxy: {
'/api': {
target: 'http://localhost:1234/',
ws: true,
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
},
}
},
pluginOptions: {},
configureWebpack: config => {
const myConfig = {
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': path.resolve(__dirname,'./'),
}
},
plugins:[
new CompressionWebpackPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\.(' +
['js', 'css'].join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
}),
],
}
return myConfig
},
chainWebpack:config => {
config.plugins.delete('prefetch')
},
}
···
1 个回复
DCloud_UNI_JBB
您好,麻烦发下可复现demo