05 Vue project to build

Vue-CLI project to build

1, built environment

  • Installation node
官网下载安装包,傻瓜式安装:https://nodejs.org/zh-cn/
  • Installation cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
  • Install scaffolding
cnpm install -g @vue/cli
  • Empty the cache processing
npm cache clean --force

2. Create a project

  • Create a project
vue create 项目名
// 要提前进入目标目录(项目应该创建在哪个目录下)
// 选择自定义方式创建项目,选取Router, Vuex插件
  • Start / Stop Project
npm run serve / ctrl+c
// 要提前进入项目根目录
  • Packaging Project
npm run build
// 要在项目根目录下进行打包操作

3, raising projects

  • Project Directory
dist: 打包的项目目录(打包后会生成)
node_modules: 项目依赖
public: 共用资源
src: 项目目标,书写代码的地方
    -- assets:资源
    -- components:组件
    -- views:视图组件
    -- App.vue:根组件
    -- main.js: 入口js
    -- router.js: 路由文件
    -- store.js: 状态库文件
vue.config.js: 项目配置文件(没有可以自己新建)
  • Profile: vue.config.js
module.exports={
    devServer: {
        port: 8888
    }
}
// 修改端口,选做
  • main.js
new Vue({
    el: "#app",
    router: router,
    store: store,
    render: function (h) {
        return h(App)
    }
})
  • .vue file
<template>
    <!-- 模板区域 -->
</template>
<script>
    // 逻辑代码区域
    // 该语法和script绑定出现
    export default {
        
    }
</script>
<style scoped>
    /* 样式区域 */
    /* scoped表示这里的样式只适用于组件内部, scoped与style绑定出现 */
</style>

Guess you like

Origin www.cnblogs.com/Du704/p/11863281.html