练习
This commit is contained in:
39
teaching/jwl/课件/es6/awaitasync.html
Normal file
39
teaching/jwl/课件/es6/awaitasync.html
Normal file
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<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">
|
||||
<title>Document</title>
|
||||
<script>
|
||||
const fs = require('fs');
|
||||
|
||||
const readFile = function (fileName) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
fs.readFile(fileName, function(error, data) {
|
||||
if (error) return reject(error);
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const gen = function* () {
|
||||
const f1 = yield readFile('/etc/fstab');
|
||||
const f2 = yield readFile('/etc/shells');
|
||||
console.log(f1.toString());
|
||||
console.log(f2.toString());
|
||||
};
|
||||
|
||||
|
||||
var gen1=async function(){
|
||||
const f1 = await readFile('/etc/fstab');
|
||||
const f2 = await readFile('/etc/shells');
|
||||
console.log(f1.toString());
|
||||
console.log(f2.toString());
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
113
teaching/jwl/课件/es6/fuxi.html
Normal file
113
teaching/jwl/课件/es6/fuxi.html
Normal file
@@ -0,0 +1,113 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<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">
|
||||
<title>Document</title>
|
||||
<script>
|
||||
// es6
|
||||
// let const
|
||||
// 解构赋值
|
||||
// async await
|
||||
// class
|
||||
// model 模块化
|
||||
// promise
|
||||
// set map weakset weakmap
|
||||
// for foreach for in while for of
|
||||
|
||||
// const set=new Set([1,2,3,3,3])
|
||||
// for(let i in set){
|
||||
// console.log(i,set[i])
|
||||
// }
|
||||
|
||||
</script>
|
||||
<script>
|
||||
const set=new Set([1,2,3,3,3])
|
||||
// console.log(set[2])
|
||||
for(let i of set){
|
||||
console.log(i,set[i])
|
||||
console.log(set)
|
||||
}
|
||||
|
||||
function zhanshi(){
|
||||
console.log(set,"lllk")
|
||||
const price=0
|
||||
}
|
||||
zhanshi()
|
||||
// console.log(price)
|
||||
|
||||
// 解构赋值
|
||||
// 对象 解构赋值 原则上来说 我们需要让属性名等于变量名
|
||||
// 特殊情况 如果说 属性名不等于属性值得话
|
||||
let {foo, baz}={foo:"aaa",bar:"bbb",baz:"ccc"}
|
||||
// foo aaaa
|
||||
// baz ccc
|
||||
// let { foo: baz } = { foo: 'aaa', bar: 'bbb' };
|
||||
console.log(foo, baz)
|
||||
|
||||
var promise=new Promise(function(resolve,reject){
|
||||
console.log(1111)
|
||||
resolve()
|
||||
})
|
||||
promise.then(()=>{
|
||||
console.log("success")
|
||||
})
|
||||
console.log(2222)
|
||||
console.log(1222223)
|
||||
setTimeout(function(){
|
||||
console.log("延迟后")
|
||||
},1000)
|
||||
|
||||
|
||||
// pro1.then(()=>{
|
||||
// pro2.then(()=>{
|
||||
// pro3.thne(()=>{
|
||||
// // .......
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
|
||||
// 用同步的样子去写异步的函数 -----async 函数(异步操作的一个方式)
|
||||
|
||||
// function getlist(){
|
||||
// http.get("/userlist").then((res)=>{
|
||||
// console.log(res)
|
||||
// })
|
||||
// }
|
||||
|
||||
// async function getlist(){
|
||||
// let res=await http.get("/userlist")
|
||||
// console.log(res)
|
||||
// }
|
||||
|
||||
|
||||
// class
|
||||
class Creator{
|
||||
constructor(name){
|
||||
this.name=name,
|
||||
this.age=1
|
||||
}
|
||||
say(){
|
||||
console.log(123)
|
||||
}
|
||||
}
|
||||
|
||||
// extends
|
||||
|
||||
class Creator2 extends Creator{
|
||||
|
||||
}
|
||||
var obj=new Creator("A")
|
||||
var obj1=new Creator("B")
|
||||
console.log(obj)
|
||||
console.log(obj1)
|
||||
|
||||
var xiaoming=new Creator2("小明")
|
||||
console.log(xiaoming)
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
86
teaching/jwl/课件/es6/promise.html
Normal file
86
teaching/jwl/课件/es6/promise.html
Normal file
@@ -0,0 +1,86 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<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">
|
||||
<title>Document</title>
|
||||
<script>
|
||||
console.log("创建proimise之前")
|
||||
var promiseobj=new Promise((resolve,reject)=>{
|
||||
console.log("创建promise")
|
||||
if (this.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
if (this.status === 200) {
|
||||
cosnole.log("mysuccess")
|
||||
resolve(this.response);
|
||||
} else {
|
||||
console.log("myerror")
|
||||
reject(new Error(this.statusText));
|
||||
}
|
||||
})
|
||||
promiseobj.then(()=>{
|
||||
console.log("success")
|
||||
|
||||
})
|
||||
console.log("promise成功之后")
|
||||
|
||||
|
||||
// readyState
|
||||
// 用promise封装ajax
|
||||
const getJSON = function(url) {
|
||||
const promise = new Promise(function(resolve, reject){
|
||||
const handler = function() {
|
||||
console.log(this.readyState)
|
||||
console.log(this.status)
|
||||
if (this.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
if (this.status === 200) {
|
||||
resolve(this.response);
|
||||
} else {
|
||||
reject(new Error(this.statusText));
|
||||
}
|
||||
};
|
||||
const client = new XMLHttpRequest();
|
||||
client.open("GET", url);
|
||||
client.onreadystatechange = handler;
|
||||
client.responseType = "json";
|
||||
client.setRequestHeader("Accept", "application/json");
|
||||
client.send();
|
||||
|
||||
});
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
|
||||
// readystate 的五种状态
|
||||
// 0 - (未初始化)还没有调用send()方法
|
||||
// 1 - (载入)已调用send()方法,正在发送请求
|
||||
// 2 - (载入完成)send()方法执行完成,已经接收到全部响应内容
|
||||
// 3 - (交互)正在解析响应内容
|
||||
// 4 - (完成)响应内容解析完成,可以在客户端调用了
|
||||
|
||||
|
||||
|
||||
getJSON("/posts.json").then(function(json) {
|
||||
console.log('Contents: ' + json);
|
||||
}, function(error) {
|
||||
console.error('出错了', error);
|
||||
});
|
||||
|
||||
async function login(){
|
||||
http("./login.php").then((res)=>{
|
||||
console.log(res)
|
||||
})
|
||||
var res=http("./login.php")
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
23
teaching/jwl/课件/vue/ceshi/.gitignore
vendored
Normal file
23
teaching/jwl/课件/vue/ceshi/.gitignore
vendored
Normal file
@@ -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?
|
||||
24
teaching/jwl/课件/vue/ceshi/README.md
Normal file
24
teaching/jwl/课件/vue/ceshi/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# ceshi
|
||||
|
||||
## Project setup
|
||||
```
|
||||
yarn install
|
||||
```
|
||||
|
||||
### Compiles and hot-reloads for development
|
||||
```
|
||||
yarn serve
|
||||
```
|
||||
|
||||
### Compiles and minifies for production
|
||||
```
|
||||
yarn build
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
```
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
||||
5
teaching/jwl/课件/vue/ceshi/babel.config.js
Normal file
5
teaching/jwl/课件/vue/ceshi/babel.config.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset'
|
||||
]
|
||||
}
|
||||
42
teaching/jwl/课件/vue/ceshi/package.json
Normal file
42
teaching/jwl/课件/vue/ceshi/package.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "ceshi",
|
||||
"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.6.5",
|
||||
"vue": "^2.6.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "~4.5.0",
|
||||
"@vue/cli-plugin-eslint": "~4.5.0",
|
||||
"@vue/cli-service": "~4.5.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"eslint": "^6.7.2",
|
||||
"eslint-plugin-vue": "^6.2.2",
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"plugin:vue/essential",
|
||||
"eslint:recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"parser": "babel-eslint"
|
||||
},
|
||||
"rules": {}
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not dead"
|
||||
]
|
||||
}
|
||||
BIN
teaching/jwl/课件/vue/ceshi/public/favicon.ico
Normal file
BIN
teaching/jwl/课件/vue/ceshi/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
17
teaching/jwl/课件/vue/ceshi/public/index.html
Normal file
17
teaching/jwl/课件/vue/ceshi/public/index.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!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>
|
||||
45
teaching/jwl/课件/vue/ceshi/src/App.vue
Normal file
45
teaching/jwl/课件/vue/ceshi/src/App.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<div>{{str}}</div>
|
||||
<div v-html="str"></div>
|
||||
name<input type="text" v-model="name">{{name}}
|
||||
<div v-if="age>=18">欢迎光临</div>
|
||||
<!-- <div v-else-if="sss"></div> -->
|
||||
<div v-else>禁止进入</div>
|
||||
<div v-for="(i,j) in arr" :key="j">
|
||||
{{i}}{{j}}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
// v-on(@)绑定是事件 v-bind(:) 绑定属性
|
||||
// v-html 解析html v-if v-else v-else-if 条件
|
||||
// 循环语句 v-for
|
||||
// npm 命令 npm run serve
|
||||
export default {
|
||||
name: 'App',
|
||||
data(){
|
||||
return{
|
||||
str:"<p>罗小黑</p>",
|
||||
name:"",
|
||||
age:16,
|
||||
arr:[1,2,3]
|
||||
}
|
||||
|
||||
},
|
||||
methods:{
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.text{
|
||||
color:red
|
||||
}
|
||||
.text1{
|
||||
color:blue;
|
||||
}
|
||||
</style>
|
||||
BIN
teaching/jwl/课件/vue/ceshi/src/assets/logo.png
Normal file
BIN
teaching/jwl/课件/vue/ceshi/src/assets/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
58
teaching/jwl/课件/vue/ceshi/src/components/HelloWorld.vue
Normal file
58
teaching/jwl/课件/vue/ceshi/src/components/HelloWorld.vue
Normal file
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div class="hello">
|
||||
<h1>{{ msg }}</h1>
|
||||
<p>
|
||||
For a guide and recipes on how to configure / customize this project,<br>
|
||||
check out the
|
||||
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
|
||||
</p>
|
||||
<h3>Installed CLI Plugins</h3>
|
||||
<ul>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
|
||||
</ul>
|
||||
<h3>Essential Links</h3>
|
||||
<ul>
|
||||
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
|
||||
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
|
||||
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
|
||||
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
|
||||
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
|
||||
</ul>
|
||||
<h3>Ecosystem</h3>
|
||||
<ul>
|
||||
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
|
||||
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
|
||||
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
|
||||
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
|
||||
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'HelloWorld',
|
||||
props: {
|
||||
msg: String
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
<style scoped>
|
||||
h3 {
|
||||
margin: 40px 0 0;
|
||||
}
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
display: inline-block;
|
||||
margin: 0 10px;
|
||||
}
|
||||
a {
|
||||
color: #42b983;
|
||||
}
|
||||
</style>
|
||||
8
teaching/jwl/课件/vue/ceshi/src/main.js
Normal file
8
teaching/jwl/课件/vue/ceshi/src/main.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import Vue from 'vue'
|
||||
import App from './App.vue'
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
new Vue({
|
||||
render: h => h(App),
|
||||
}).$mount('#app')
|
||||
8514
teaching/jwl/课件/vue/ceshi/yarn.lock
Normal file
8514
teaching/jwl/课件/vue/ceshi/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
28
teaching/jwl/课件/vue/note.md
Normal file
28
teaching/jwl/课件/vue/note.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# vue
|
||||
|
||||
## vue cli 常用命令
|
||||
* vue create 创建项目
|
||||
* vue --version 查看版本(版本在3以上)
|
||||
* cd + 项目文件夹的名字 进入项目文件夹目录
|
||||
* npm run serve
|
||||
yarn serve
|
||||
运行
|
||||
|
||||
|
||||
## 目录结构
|
||||
node_modules 安装的第三方的库会在这里面
|
||||
public 忽略掉
|
||||
.gitignore git 上传的时候用来规定忽略文件的
|
||||
package.json 记录项目中用的依赖 名字+版本
|
||||
src 项目主体
|
||||
assets 静态文件(默认)
|
||||
static 静态文件(常用)
|
||||
components 存放组件
|
||||
pages 存放页面
|
||||
app.vue 入口文件
|
||||
|
||||
|
||||
## 基本结构
|
||||
template html
|
||||
script js
|
||||
style css
|
||||
Reference in New Issue
Block a user