(已解決)服務(wù)器輸出的app文件路徑和vuerouter配置里面的一一對(duì)應(yīng)才行
vue-cli打包之后,頁(yè)面的js在控制臺(tái)都可以看到有內(nèi)容返回,頁(yè)面也沒(méi)有任何的報(bào)錯(cuò),可就是不加載組件出來(lái)效果,什么原因???
服務(wù)器上返回的頁(yè)面也有(往下看圖,有app.vue的靜態(tài)html)
我實(shí)在是無(wú)招可用了,求指教
ps:網(wǎng)上搜了一堆都是說(shuō)改webpack的config/index.js,吧“/”改成“./”我也改了,打包出來(lái)的效果一樣,還有的說(shuō)吧mode: 'history'注釋掉,我也注釋了,打包依舊,什么情況???懵逼中……
由于沒(méi)有報(bào)錯(cuò),我自己猜八成是路徑問(wèn)題,最后賭了一手路徑,試著改了router/router.js下的base: "路徑",改成和服務(wù)器輸出的路徑一樣,最后出來(lái)效果了。
服務(wù)器輸出的是http://localhost:3000/admin/main.html(這是app的內(nèi)容),對(duì)應(yīng)的base選項(xiàng)填上/admin/main.html
謝邀.先看一遍問(wèn)題.
剛看完問(wèn)題情況,然后拷貝了一份新建的項(xiàng)目來(lái)測(cè)試.并沒(méi)有復(fù)現(xiàn)你所說(shuō)的情況...
以下是router.js
import Vue from 'vue'
import Router from 'vue-router'
const index = () => import(/* webpackChunkName: "group-index" */ '@/page/index.vue')
// import index from '@/page/index.vue'
import home from '@/page/home.vue'
import proof_company from '@/page/proof_company.vue'
import proof_huji from '@/page/proof_huji.vue'
import proof_salary from '@/page/proof_salary.vue'
import printSettings from '@/page/printSettings.vue'
import printProgress from '@/page/printProgress.vue'
import makeCard from '@/page/makeCard.vue'
import rate from '@/page/rate.vue'
import admin from '@/page/admin.vue'
Vue.use(Router)
export default new Router({
routes: [{
path: '/',
redirect: '/index'
},
{
path: '/index',
component: index
},
{
path: '/admin',
component: admin
},
{
path: '/home',
component: home,
children: [{
path: 'proof_company',
component: proof_company,
},
{
path: 'proof_huji',
component: proof_huji,
},
{
path: 'proof_salary',
component: proof_salary,
},
{
path: 'printSettings',
component: printSettings,
},
{
path: 'printProgress',
component: printProgress,
},
{
path: 'makeCard',
component: makeCard,
},
{
path: 'rate',
component: rate,
}
]
}
]
})
以下是config/index.js的build部分
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './',
/**
* Source Maps
*/
productionSourceMap: true,
// https://webpack.js.org/configuration/devtool/#production
devtool: '#source-map',
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
}
}
以下是index.vue部分
<style lang="less" scoped>
.csot_wrapper {
width:900px;
height:600px;
background-color: pink;
}
</style>
<template>
<div class="csot_wrapper">
test words
</div>
</template>
<script>
export default {
//props:{
//props:{
//type:String,
//default:String,
//},
//},
//data () {
//return {
//}
//},
//methods:{
//example(){
////dosth
//},
//},
//computed:{
//computedA(){
//return xxx
//},
//},
//watch:{
//watchA(val,oldval){//必須是data||props里面已經(jīng)有的key才行,普通值
////dosth
//},
//watchB:{//必須是data||props里面已經(jīng)有的key才行,對(duì)象obj
//deep:true,
//handler(val,oldval){
////dosth
//}
//},
//},
created () {
console.log('index.vue created' + +new Date())
},
//mounted () {
//},
//beforeDestroy () {
//},
//beforeRouteEnter(to, from, next) {
//next(vm => {
//// 通過(guò) `vm` 訪問(wèn)組件實(shí)例
//});
//},
//beforeRouteLeave(to, from, next){
//// dosth 可以用this訪問(wèn)當(dāng)前組件上下文
//next();
//},
}
</script>
...得,官網(wǎng)上有注明 ,我去看了下我的依賴
注意
如果您使用的是 Babel,你將需要添加 syntax-dynamic-import 插件,才能使 Babel 可以正確地解析語(yǔ)法。
"babel-plugin-syntax-jsx": "^6.18.0"
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國(guó)家
北大青鳥中博軟件學(xué)院創(chuàng)立于2003年,作為華東區(qū)著名互聯(lián)網(wǎng)學(xué)院和江蘇省首批服務(wù)外包人才培訓(xùn)基地,中博成功培育了近30000名軟件工程師走向高薪崗位,合作企業(yè)超4
中公教育集團(tuán)創(chuàng)建于1999年,經(jīng)過(guò)二十年潛心發(fā)展,已由一家北大畢業(yè)生自主創(chuàng)業(yè)的信息技術(shù)與教育服務(wù)機(jī)構(gòu),發(fā)展為教育服務(wù)業(yè)的綜合性企業(yè)集團(tuán),成為集合面授教學(xué)培訓(xùn)、網(wǎng)
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
曾工作于聯(lián)想擔(dān)任系統(tǒng)開(kāi)發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_(kāi)發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開(kāi)發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開(kāi)發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開(kāi)發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問(wèn),美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。