在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue 開發(fā)模式?jīng)]問題,打了包之后一直提示$找不到,已經(jīng)在index.html引

vue 開發(fā)模式?jīng)]問題,打了包之后一直提示$找不到,已經(jīng)在index.html引入了

圖片描述

plugins:[

new webpack.DefinePlugin({    //生成模式
  'process.env': {
    NODE_ENV: '"production"'
  }
}),
new webpack.optimize.CommonsChunkPlugin({name:'vendors',filename:'src/assets/js/vendors.js'}),   //提出公用模塊
new webpack.optimize.UglifyJsPlugin({     //混淆js
  sourceMap: true,
  compress: {
    warnings: false
  }
}),
new webpack.LoaderOptionsPlugin({   //壓縮css,自動(dòng)補(bǔ)全前綴
  options:{
    postcss: function () {
    return [precss,autoprefixer];
    },
    minimize: true
    }
}),
new HtmlWebpackPlugin({     //生成html模版
        filename: 'index.html',
        template:__dirname+'/my-index.html',
        inject:'body',
        hash:true
    }),
new CleanWebpackPlugin(['dist'],{    //清楚已打包
    verbose: true,
    dry: false,
}),

new ExtractTextPlugin('src/assets/css/[name].[chunkhash:8].css') //單獨(dú)提出css打包
]

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0,user-scalable=no" />
<script src="http://res.wx.qq.com/open/js/...;></script>
<script src="src/assets/js/jquery-3.2.1.min.js"></script>
<script src='src/assets/js/common.js'></script>

回答
編輯回答
殘淚

你這個(gè)問題太常見
開發(fā)放在src下面沒問題
但是你打包只有static目錄 這樣肯定會(huì)導(dǎo)致路徑有問題

建議 放在static目錄下 已static該目錄路徑引入jq??! 然后打包也沒有問題

2018年5月22日 09:20
編輯回答
司令

假設(shè)index.html在項(xiàng)目根目錄下,且jQuery文件放在了根目錄下的assets文件夾中
相對(duì)路徑:<script src="./assets/js/jquery-3.2.1.min.js"></script>
絕對(duì)路徑:<script src="/assets/js/jquery-3.2.1.min.js"></script>

2017年2月2日 11:48