小程序初始化

1.src文件目录

  • app.vue
1
2
3
4
5
6
//app.vue中不需要有template
<script>
export default {};
</script>
<style scoped>
</style>
  • main.js
1
2
3
4
5
6
7
8
import Vue from 'vue'
import App from './app.vue'


App.mpType = 'app'
const app = new Vue(App)
// 挂载整个应用
app.$mount()
  • app.json
1
2
3
4
5
6
//后续创建pages/index/main.js文件
{
"pages": [
"pages/index/main"
]
}
  • pages

    • index

      • index.vue
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      <template>
      <div>
      <p>index</p>
      </div>
      </template>
      <script>
      export default {};
      </script>
      <style scoped>
      </style>
      • main.js
      1
      2
      3
      4
      5
      import Vue from 'vue'
      import Index from './index.vue'

      const index = new Vue(Index)
      index.$mount()