使用脚手架渲染demo页面

new_branch1
roger 2 years ago
parent 38b064a3b0
commit e428f2dd99
  1. 3
      19_单文件组件/main.js
  2. 23
      19_单文件组件/vue_demo/.gitignore
  3. 24
      19_单文件组件/vue_demo/README.md
  4. 5
      19_单文件组件/vue_demo/babel.config.js
  5. 19
      19_单文件组件/vue_demo/jsconfig.json
  6. 19327
      19_单文件组件/vue_demo/package-lock.json
  7. 43
      19_单文件组件/vue_demo/package.json
  8. BIN
      19_单文件组件/vue_demo/public/favicon.ico
  9. 21
      19_单文件组件/vue_demo/public/index.html
  10. 20
      19_单文件组件/vue_demo/src/App.vue
  11. BIN
      19_单文件组件/vue_demo/src/assets/logo.png
  12. 49
      19_单文件组件/vue_demo/src/components/School.vue
  13. 36
      19_单文件组件/vue_demo/src/components/Student.vue
  14. 17
      19_单文件组件/vue_demo/src/main.js
  15. 5
      19_单文件组件/vue_demo/vue.config.js

@ -2,8 +2,7 @@ import App from './App.vue'
new Vue({ new Vue({
el: "#root", el: "#root",
template: ` template: `<App/>`,
<App/>`,
components: { components: {
App App
} }

@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

@ -0,0 +1,24 @@
# vue_demo
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,43 @@
{
"name": "vue_demo",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.8.3",
"vue": "^2.6.14"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"vue-template-compiler": "^2.6.14"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<!-- 针对IE浏览器的特殊设置 -->
<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>

@ -0,0 +1,20 @@
<template>
<div>
<img src="./assets/logo.png" alt="logo">
<School/>
<Student/>
</div>
</template>
<script>
//
import School from './components/School'
import Student from './components/Student'
export default {
name: "App",
components: {
School,
Student
}
}
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

@ -0,0 +1,49 @@
<template>
<!-- 组件的模板标签 -->
<div class="demo">
<h2>学校名称{{ schoolName }}</h2>
<h2>学校地址{{ address }}</h2>
<button @click="showName">点我提示学校名</button>
</div>
</template>
<!-- 组件的交互标签 -->
<script>
export default {
name: 'School',
data() {
return {
schoolName: '尚硅谷',
address: '北京'
}
},
methods: {
showName() {
alert(this.schoolName)
}
}
}
// const school = Vue.extend({
// data() {
// return {
// schoolName: '',
// address: ''
// }
// },
// methods: {
// showName(){
// alert(this.schoolName)
// }
// }
// })
//
// export default school
</script>
<!-- 组件的样式标签 -->
<style>
.demo {
background-color: orange;
}
</style>

@ -0,0 +1,36 @@
<template>
<!-- 组件的模板标签 -->
<div>
<h2>学生名称{{ name }}</h2>
<h2>学生年龄{{ age }}</h2>
</div>
</template>
<!-- 组件的交互标签 -->
<script>
export default {
name: 'Student',
data() {
return {
name: '小强',
age: '18'
}
},
}
// const school = Vue.extend({
// data() {
// return {
// schoolName: '',
// address: ''
// }
// },
// methods: {
// showName(){
// alert(this.schoolName)
// }
// }
// })
//
// export default school
</script>

@ -0,0 +1,17 @@
// 引入Vue
import Vue from 'vue'
// 引入App
import App from './App.vue'
Vue.config.productionTip = false
// 创建Vue实例
new Vue({
render: h => h(App),
}).$mount('#app')
// el的写法
// new Vue({
// el: '#App',
// render: h => h(App),
// })

@ -0,0 +1,5 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false
})
Loading…
Cancel
Save