摘要: 1 安装工具babel-cli babel-preset-env browserify(webpack) .babelrc配置 { presets":["babel-preset-env"] 2 npx babel src/js -d dist/js 3 打包 npx browserify dist 阅读全文
posted @ 2023-02-20 16:02 罗砂 阅读(57) 评论(0) 推荐(0)
摘要: NPM和模块化结合使用 前提是要先安装node.js 如果在vscode的终端中一直不成功的话,可以在cmd里,以管理员身份来安装jquery: 使用方法: //修改背景颜色为粉色 // ES6引入jquery写法 import $ from 'jquery';// 类似于node.js:const 阅读全文
posted @ 2023-02-20 16:00 罗砂 阅读(36) 评论(0) 推荐(0)
摘要: 模块化 模块化是指将一个大的程序文件 ,拆分成许多小的文件,然后将小文件组合起来。 模块化的好处 模块化的优势有以下几点: 1.防止命名冲突 2.代码复用 3.高维护性 export是暴露的意思 引入js文件然后打印 htm: <script type="module"> import * as m 阅读全文
posted @ 2023-02-20 14:45 罗砂 阅读(24) 评论(0) 推荐(0)
摘要: Object.assign 对象的合并 <script> // Object.assign 对象的合并 const config1={ host:'localhost', port:3306, name:'root', pass:'root', test:'test' } const config2 阅读全文
posted @ 2023-02-20 14:03 罗砂 阅读(14) 评论(0) 推荐(0)
摘要: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script> class Phone{ // 构造方法 constructor(brand,price){ this.brand 阅读全文
posted @ 2023-02-20 11:34 罗砂 阅读(25) 评论(0) 推荐(0)
摘要: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script> function Phone(brand,price){ this.brand = brand this.pric 阅读全文
posted @ 2023-02-20 11:21 罗砂 阅读(17) 评论(0) 推荐(0)
摘要: <script> //ES5 //手机类 // function Phone(brand,price){ // this.brand = brand; // this.price = price; // } // Phone.phoneName = '手机'; // //添加方法 // Phone. 阅读全文
posted @ 2023-02-20 10:58 罗砂 阅读(16) 评论(0) 推荐(0)
摘要: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script> class Shouji{ // 构造方法 名字不能修改 constructor(brand,price){ th 阅读全文
posted @ 2023-02-20 10:50 罗砂 阅读(19) 评论(0) 推荐(0)
摘要: 介绍 ES6 提供了 Map 数据结构。它类似于对象,也是键值对的集合。但是“键的范围不限于字符串,各种类型的值(包括对象) 都可以当作键。Map 也实现了 iterator 接口,所以可以使用[扩展运算符]和 [for...of...] 进行遍历。Map的属性和方法: 1.size 返回Map的元 阅读全文
posted @ 2023-02-20 10:28 罗砂 阅读(26) 评论(0) 推荐(0)
摘要: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>set集合实践</title> </head> <body> <div id="ad"> </div> <div></div> <script> let arr 阅读全文
posted @ 2023-02-20 10:07 罗砂 阅读(21) 评论(0) 推荐(0)
摘要: set方法可以去重数组 // 声明一个set let e = new Set() let ess = new Set(['张三','李四','王五','李四']) console.log(ess); 寻找元素个数 console.log(ess.size); 添加新的元素 ess.add('赵六') 阅读全文
posted @ 2023-02-20 09:38 罗砂 阅读(32) 评论(0) 推荐(0)
摘要: 调用then方法 then方法返回结果是Promise对象,对象状态由回调函数的执行结果决定 如果回调函数中返回的结果是非promise类型的属性,状态为成功,返回值为对象的成功 then方法是可以只指定一个回调的 <script> // 创建Promise对象 const p =new Promi 阅读全文
posted @ 2023-02-20 09:00 罗砂 阅读(226) 评论(0) 推荐(0)