Ver código fonte

修改配置

develop
燕鹏 4 anos atrás
pai
commit
616602928a
  1. BIN
      public/favicon.ico
  2. 20
      public/index.html
  3. 62
      src/app/App.vue
  4. 28
      src/app/main.js
  5. 4
      src/app/router.js
  6. 1
      src/index/App.vue
  7. 4
      src/index/router.js
  8. 26
      src/router/router.js
  9. 29
      src/subpage/App.vue
  10. 12
      src/subpage/main.js
  11. 5
      src/subpage/views/About.vue
  12. 21
      src/subpage/views/Home.vue
  13. 0
      src/views/About.vue
  14. 0
      src/views/Home.vue
  15. 6
      vue.config.js

BIN
public/favicon.ico

Binary file not shown.

Depois

Largura:  |  Altura:  |  Tamanho: 1.1 KiB

20
public/index.html

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>首页</title>
</head>
<body>
<noscript>
<strong>We're sorry but multipage doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

62
src/app/App.vue

@ -0,0 +1,62 @@
<template>
<div id="app">
<div id="nav">
<p>我是app页面,当前appId {{ appId }}</p>
<router-link to="/">Home</router-link>
<router-link to="/about">About</router-link>
</div>
<router-view/>
</div>
</template>
<script>
import HelloWorld from "@/components/HelloWorld";
export default {
name: 'home',
components: {
HelloWorld
},
data() {
return {
appId: ''
}
},
mounted() {
if (this.$route.query.appId) {
this.appId = this.$route.query.appId
}
let search = window.location.search
if (search.indexOf('appId') !== -1) {
if (search.indexOf('&') === -1) {
this.appId = search.substring(7)
} else {
let str = search.substring(7)
this.appId = str.substring(0, str.indexOf('&'))
}
}
console.log(`这个是默认页面的主页:${this.$store.state.myname}`)
}
}
</script>
<style lang="less">
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
a {
font-weight: bold;
color: #2c3e50;
&.router-link-exact-active {
color: #42b983;
}
}
}
</style>

28
src/app/main.js

@ -0,0 +1,28 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from '@/store'
Vue.config.productionTip = false
router.beforeEach((to, from, next) => {
if (!to.query.appId) {
if (from.query.appId) {
to.query.appId = from.query.appId
} else {
to.query.appId = window.location.href.match(/appId=(.*)/)[1]
}
}
next()
})
router.afterEach((to, from) => {
})
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')

4
src/subpage/router.js → src/app/router.js

@ -1,7 +1,7 @@
import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import About from './views/About.vue'
import Home from '@/views/Home.vue'
import About from '@/views/About.vue'
Vue.use(Router)

1
src/index/App.vue

@ -1,6 +1,7 @@
<template>
<div id="app">
<div id="nav">
<p>我是默认页面 <a href="app.html?appId=asdfghjkl" target="_blank">跳轉到APP</a></p>
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>

4
src/index/router.js

@ -1,7 +1,7 @@
import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import About from './views/About.vue'
import Home from '@/views/Home.vue'
import About from '@/views/About.vue'
Vue.use(Router)

26
src/router/router.js

@ -0,0 +1,26 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
component: () => import(/* webpackChunkName: "about" */ '@/views/About.vue')
}
]
const router = new VueRouter({
// mode: 'history',
base: process.env.BASE_URL,
routes
})
export default router

29
src/subpage/App.vue

@ -1,29 +0,0 @@
<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<router-view/>
</div>
</template>
<style lang="less">
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
a {
font-weight: bold;
color: #2c3e50;
&.router-link-exact-active {
color: #42b983;
}
}
}
</style>

12
src/subpage/main.js

@ -1,12 +0,0 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from '@/store'
Vue.config.productionTip = false
new Vue({
router,
store,
render: h => h(App)
}).$mount('#app')

5
src/subpage/views/About.vue

@ -1,5 +0,0 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>

21
src/subpage/views/Home.vue

@ -1,21 +0,0 @@
<template>
<div class="home">
<img src="@/assets/logo.png">
<HelloWorld msg="多页面测试页"/>
</div>
</template>
<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
export default {
name: 'home',
components: {
HelloWorld
},
mounted() {
console.log(`这个是多页面测试页的主页:${this.$store.state.myname}`)
}
}
</script>

0
src/index/views/About.vue → src/views/About.vue

0
src/index/views/Home.vue → src/views/Home.vue

6
vue.config.js

@ -9,8 +9,8 @@ module.exports = {
// build 生成的文件名称 例: dist/index.html
filename: 'index.html'
},
// template 默认会去找 public/subpage.html 页面,如果找不到会使用 public/index.html 文件
// 输出文件会默认的推断为 subpage.html
subpage: 'src/subpage/main.js'
// template 默认会去找 public/app.html 页面,如果找不到会使用 public/index.html 文件
// 输出文件会默认的推断为 app.html
app: 'src/app/main.js'
}
}

Carregando…
Cancelar
Salvar