Giter Site home page Giter Site logo

webpack-multiple-pages's Introduction

webpack 打包vue多页面应用

quickstart

#clone registry
git clone [email protected]:liuziyang/vue-multiple.git

cd vue-multiple

# install dependencies
npm install

# serve with hot reload at localhost:8000
npm run dev

# build for production with minification
npm run build

use

项目结构

项目结构类似 vue 单页应用配置

src: 项目源文件

src/components : 通用组件

src/views/** : 页面文件

src/views/** /index.js: 页面的入口文件

src/views/** /app.vue : 使用单文件组件时的根组件

打包时会针对 src/views 目录下的子文件夹生成对应的页面,页面名称与文件夹名称相同。

单文件组件

项目中可以使用单文件组件,需要在每个文件夹下提供根组件组件

示例:

// ~src/views/index/app.vue

<template>
  <div class="index"></div>
</template>

export default {
  beforeCreate () {
    document.title = 'vue 多页面应用开发'
  },
}

注意: 由于使用的html模板文件统一是项目根目录下的index.html,所以对应的title应该在每个页面的根组件中使用 document.title 来修改。

// 入口文件
// ~src/views/index/index.js

import Vue from 'vue'
import App from './app.vue'

new Vue({
  el: '#app',
  render: h => h(App)
})

注意:入口文件名称统一使用了index.js

webpack-multiple-pages's People

Contributors

mt51 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.