2021-10-30 vue笔记-脚手架vue-cli(二) 项目文件介绍和vue-eslint

1.入口主页面:index.htrml
<!DOCTYPE html>
<html lang="">
  <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><%= htmlWebpackPlugin.options.title %></title>
  </head>
  <body>
    <noscript>
      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> 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>
2.vue的入口文件,vue文件初始化位置:main.js
// 这是ES6导入规范
import Vue from 'vue' // 这是CommonJS导入规范: ar vue = require("vue")
import App from './App.vue'

// import helloworld from './components/HelloWorld.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false

new Vue({
        router,
        store,
        render: h => h(App)//渲染单文件组件App.vue
    }).$mount('#app') //使用函数mount函数挂载节点#app上,对应index.html中的<div id="app"></div>
3.汇总所有组件的根组件:App.vue

快捷键:空.vue文件中输入vue回车

<template>
  <div id="app">
      <!-- 3.组件调用 -->
    <Navbar></Navbar>
  </div>
</template>
<script>
//引入vue
import Vue from "vue"
// 1.组件引入
import Navbar from "./components/Navbar"
// 2.全局组件注册
Vue.component("Navbar",Navbar);//前面的"Navbar"是组件名,后面的Navbar是引入的外部组件注册

// 这是CommonJS的导出方式:module.exports
// 这是ES6的导出方式
	export default {

	}
</script>
<style>

</style>
4.外部单文件组件(首字母大写):Navbar.vue
<template>
  <div>
    我是sidebar
  </div>
</template>

<script>
export default {

}
</script>
<style lang="scss" scoped>
 // 1.lang="scss"表示支持sass样式
/*解决报错(sass-loader未安装):Can't resolve 'sass-loader'
命令:npm install sass-loader -D*/
// 2.scope作用域表示此style标签中的样式仅影响当前组件

</style>
5.vue-eslint:纠正语法和风格错误

ESLint是一个QA工具,用来避免低级错误和统一代码的风格,ESLint的主要用途:
审查代码是否符合编码规范和统一的代码风格;
审查代码是否存在语法错误;
命令:npm run lint

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

前端OnTheRun

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值