let arr = [1, 2, 3]
let [x, y, z] = arr
console.log(x,y,z)
let user = {
name: "jack",
age: 29
}
let { name, age } = user
console.log(name, age)
let name = 'jack'
let age = '99'
console.log(`我是${name},年龄是${age}`)
console.log(`第一行,
第二行`)
let name = 'jack'
let age = '99'
let person = {
name,
age
}
console.log(person)
let person = {
name: "jack",
// sayHi: function () {
// console.log("hi")
// }
sayHi() {
console.log("hi")
}
}
console.log(person.sayHi)
let person = {
name: 'jack',
age: 23
}
let own = { ...person }
own.name = 'rose'
console.log(person.name)
function showMsg(name, age) {
console.log(name,age)
}
function showMsg(name) {
console.log(name)
}
//会调用第二个方法,不会调用第一个
showMsg("jack",23)
console.log('100' == 100) //true
console.log('100' === 100) //false
//age赋默认值23
function showMsg(name, age = 23) {
//这里是undifined判断,不是null判断
if (!age) {
console.log(name, age)
} else {
console.log(name)
}
}
showMsg("jack")
showMsg("jack", null)
showMsg("jack", undefined)
{{name}}
Document
选择框
{{ok}}
Document
- {{item.id}}
- {{item.name}}
{{name}}
getlist(){
let _this = this
axios.get("http://127.0.0.1:8110/admin/edu/teacher/list").then(function(res){
_this.dataList = res.data
_this.name = "jack"
}).catch(err=>console.log(err))
}
//基础配置:返回值是一个函数
initRequest() {
return axios.create({
baseURL: 'http://localhost:8110',
timeout: 5000
})
},
//api调用
teacherListApi() {
//request是一个函数
let request = this.initRequest()
return request({
url: '/admin/edu/teacher/list',
method: 'get'
})
},
//数据渲染
getTeacherList2() {
console.log('getTeacherList2')
this.teacherListApi().then(response => {
this.dataList = response.data
}).catch(error => {
console.log(error)
})
}
Document
{{scope.row.level === 1 ? "高级讲师" : "普通讲师"}}
npm config list
npm install xx@xx
npm install -g xx
export default {
getList() {
console.log("get list")
},
setList() {
console.log("set list")
}
}
import teacher from "./teacherApi.js"
teacher.getList()
teacher.setList()
npm install -g babel-cli
新建.babelrc
添加配置
{
"presets": [ "es2015"],
"plugins": []
}
npm install -D babel-preset-es2015
babel src -d dist
export function getList() {
console.log("get list")
}
export function setList() {
console.log("set list")
}
import {getList, setList} from "./teacherApi.js"
getList()
setList()
npm install webpack webpacck-cli
const path = require("path") //Node.js内置模块
module.exports = {
entry: './src/main.js', //配置入口文件
output: {
path: path.resolve(__dirname, './dist'), //输出路径,__dirname:当前文件所在路径
filename: 'bundle.js' //输出文件
},
module: {
rules: [
{
test: /\.css$/, //打包规则应用到以css结尾的文件上
use: ['style-loader', 'css-loader']
}
]
}
}
webpack --mode=development
webpack只认识js,打包css需要loader插件
css-loader:将css装载到js上
style-loader:让js认识css
插件安装
npm install -D css-loader style-loader
const path = require("path") //Node.js内置模块
module.exports = {
entry: './src/main.js', //配置入口文件
output: {
path: path.resolve(__dirname, './dist'), //输出路径,__dirname:当前文件所在路径
filename: 'bundle.js' //输出文件
},
module: {
rules: [
{
test: /\.css$/, //打包规则应用到以css结尾的文件上
use: ['style-loader', 'css-loader']
}
]
}
}
const common = require('./common.js')
const utils = require('./utils.js')
require("../css/style.css")
common.getName()
utils.getAge()
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack --mode=development"
}
exports.getName = function () {
console.log("jack")
}
exports.getAge = function () {
console.log("12")
}
const common = require('./common.js')
const utils = require('./utils.js')
common.getName()
utils.getAge()