HTML、CSS、JS、jQuery Vue2 CDN模式
快速安装 vscode + live server插件
在桌面建一个文件夹,新建一个文件index.html 使用vscode打开文件夹访问index.html
学习网站
html+css+javascript 文档网站
简称mdn,对当下html, css, javascript 描述具有权威的解释之一的网站
mdn链接
html+css常用代码
html+css常用代码
vue-demo页面
vue-demo页面
vue2官网
vue2官网
ui框架官网 element ui
ui框架官网 element ui
学习视频
html+css的学习视频:
html+css的学习视频
javascript+jquery的学习视频:
javascript+jquery的学习视频
vue2+vue3的学习视频,只看vue2的部分:
vue2+vue3的学习视频,只看vue2的部分
html节点
| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="UTF-8"> |
| |
| <title>文档标题</title> |
| <meta name="Keywords" content="英文逗号分隔的关键词列表(始终与页面有关)"> |
| <meta name="Description" content="页面描述,150字内,搜索引擎根据选择此描述来显示搜索结果。"> |
| |
| <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover" /> |
| |
| |
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| |
| |
| <meta name="renderer" content="webkit"> |
| |
| |
| <meta http-equiv="Expires" content="0"> |
| <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> |
| <meta http-equiv="Pragma" content="no-cache" /> |
| <style> |
| a{ |
| text-decoration: none; //不要下划线 |
| } |
| #container{ |
| display: flex; |
| align-items: center; |
| } |
| </style> |
| </head> |
| <body> |
| <div id="container"> |
| <span class="container-text">111<span> |
| <span class="container-text">222<span> |
| </div> |
| <a href="https://www.baidu.com"> |
| <img src="https://www.qianduange.cn/upload/article/banner.png"> |
| |
| <h1>大标题全文唯一</h1> |
| <h2>副标题</h2> |
| <h6>最小标题</h6> |
| |
| <form> |
| <input type="text" placeholder="输入文本" value="" > |
| <input type="hidden" placeholder="隐藏域" value="" > |
| <input type="radio" placeholder="单选" name="" id=""> |
| <input type="checkbox" placeholder="多选" name="" id=""> |
| <textarea placeholder="多行文本" name="" id=""></textarea> |
| </form> |
| |
| <script> |
| var a=1; |
| console.log(a); |
| <script> |
| </body> |
| </html> |
| |
复制
css节点
| width: 365px; |
| height: 32px; |
| |
| font-size: 34px; |
| color: #333333; |
| line-height: 38px; |
| text-align : center; |
| font-family: PingFang SC, '微软雅黑'; |
| font-weight: bold; |
| |
| background-color: #FFFFFF; |
| background: url('//assets.huibo.com/images/bg_login.png') no-repeat; |
| background-size: 100% 100%; |
| |
| border : 1px solid #eee; |
| |
| border-radius : 10px; |
| border-radius : 10px 10px 10px 10px; |
| |
| float:left; float:right; |
| |
| position : absolute; |
| position : relative |
| position : fixed |
| z-index:1; |
| left:0; |
| top:0; |
| right:0; |
| bottom:0; |
| overflow: hidden; |
| overflow: visible; |
| margin: 10px 20px 30px 40px; 兄弟节点使用使用margin |
| padding: 10px 20px 30px 40px; 父子节点使用padding |
| margin-top: 10px; |
| padding-top: 10px; |
| |
| display : block; ///块级元素 |
| display : inline-block; //行内元素 |
| |
| |
| display : flex; |
| align-items : center; |
| |
| |
| display : flex; |
| justify-content : center; |
| |
| |
| display : flex; |
| align-items : center; |
| justify-content : center; |
| |
| |
| .list{ |
| display: flex; |
| flex-wrap: wrap; |
| } |
| .item{ |
| flex-shrink: 0; |
| margin: 0 16rpx 16rpx 0; |
| } |
| |
| |
| |
| :hover{ |
| |
| } |
| :active{ |
| |
| } |
| :first-child 和 :last-child{ |
| |
| } |
| :nth-child(1){ |
| |
| } |
| |
| |
| word-break: break-all; |
| |
| |
| .ellipsis{ |
| overflow: hidden; |
| white-space: nowrap; |
| word-break: break-all; |
| text-overflow: ellipsis; |
| } |
| .ellipsis2{ |
| text-overflow: -o-ellipsis-lastline; |
| overflow: hidden; |
| text-overflow: ellipsis; |
| display: -webkit-box; |
| -webkit-line-clamp: 2; |
| line-clamp: 2; |
| -webkit-box-orient: vertical; |
| } |
| |
| |
| ::-webkit-input-placeholder{ |
| color: #cccfdb; |
| } |
| :-moz-placeholder{ |
| color: #cccfdb; |
| } |
| ::-moz-placeholder{ |
| color: #cccfdb; |
| } |
| :-ms-input-placeholder{ |
| color: #cccfdb; |
| } |
| |
| .clearfix:after{ |
| content: ""; |
| display: block; |
| height: 0; |
| clear: both; |
| visibility: hidden; |
| } |
| |
| *{ |
| scrollbar-width: thin; |
| } |
| |
| ::-webkit-scrollbar { |
| width: 5px; |
| border-radius: 5px; |
| } |
| ::-webkit-scrollbar-thumb{ |
| background-color: #DCDEEC; |
| border-radius: 5px; |
| cursor: pointer; |
| } |
| ::-webkit-scrollbar-thumb:hover{ |
| background-color: #9a9ba5; |
| } |
| |
复制
JavaScript编程基础
| alert('1111') |
| |
| |
| |
| var a=1; |
| let a=1; |
| const a=1; |
| |
| let name = "Alice"; |
| let isStudent = true; |
| |
| |
| if(name == 'Alice'){ |
| console.log('我是Alice') |
| }else if(name == 'Tom'){ |
| console.log('Tom') |
| }else{ |
| console.log('我是谁?') |
| } |
| |
| document.getElementById("container1") |
| document.getElementsByClassName("container2") |
| document.getElementsByTagName('h1') |
| document.querySelector(".container2") |
| document.querySelectorAll(".container2") |
| document.createElement() |
| document.appendChild() |
| document.removeChild() |
| |
| addEventListener() |
| removeEventListener() |
| |
| var setTimeoutAlert = setTimeout(funtion(){ |
| alert('1秒后执行') |
| },1000) |
| clearTimeout(setTimeoutAlert) |
| |
| var a=1; |
| var setAdd = setInterval(funtion(){ |
| a++; |
| },1000) |
| clearInterval(setAdd) |
| |
| cookie |
| |
| localStorage和sessionStorage |
复制
String字符串常见操作
1. 字符串连接
使用 +
运算符可以将多个字符串连接在一起。
| let str1 = "Hello, "; |
| let str2 = "world!"; |
| let result = str1 + str2; |
| console.log(result); |
复制
2. 字符串长度
使用 length
属性获取字符串的长度。
| let text = "Hello"; |
| console.log(text.length); |
复制
3. 字符串查找
返回指定值首次出现的位置,如果未找到则返回 -1
。
| let str = "Hello, world!"; |
| console.log(str.indexOf("world")); |
复制
4. 字符串提取
-
slice(start, end)
:提取从 start
到 end
(不包括 end
)之间的字符。
| let str = "Hello, world!"; |
| console.log(str.slice(0, 5)); |
复制
-
substring(start, end)
:类似于 slice()
,但是不能接受负数作为参数。
| console.log(str.substring(7, 12)); |
复制
-
substr(start, length)
:从 start
开始提取指定长度的字符。
| console.log(str.substr(7, 5)); |
复制
5. 字符串替换
-
replace(oldValue, newValue)
:替换某个子字符串为新的子字符串。注意默认只替换第一次出现的匹配项。
| let str = "Hello, world!"; |
| console.log(str.replace("world", "JavaScript")); |
复制
若要替换所有匹配项,可以使用正则表达式并添加全局标志 g
:
| let text = "one two one two"; |
| console.log(text.replace(/one/g, "three")); |
复制
6. 字符串大小写转换
7. 字符串拆分
-
split(separator, limit)
:根据指定的分隔符分割字符串,返回一个数组。
| let str = "apple,banana,cherry"; |
| console.log(str.split(",")); |
复制
8. 字符串模板(ES6)
使用反引号(`
)创建模板字符串,允许嵌入变量和表达式。
| let name = "Alice"; |
| let age = 25; |
| console.log(`My name is ${name} and I am ${age} years old.`); |
| |
复制
这些只是JavaScript中一些基本的字符串操作方法。通过组合使用这些方法,可以实现更复杂的字符串处理逻辑,满足各种开发需求。
Array数组常见操作
循环
| let arr = [1, 2, 3]; |
| for(let i=0; i<arr.length; i++){ |
| console.log(arr[i]); |
| } |
复制
使用 forEach 循环遍历数组
| let arr = [1, 2, 3]; |
| arr.forEach(function(value) { |
| console.log(value); |
| }); |
复制
添加元素到数组的末尾
| let arr = [1, 2, 3]; |
| arr.push(4); |
| console.log(arr); |
复制
在数组开头添加一个或多个元素,并返回数组的新长度。
| let arr = [1, 2, 3]; |
| arr.unshift(0); |
| console.log(arr); |
复制
根据索引位置移除数组中的元素,还可以指定要移除的元素数量。
| let arr = [1, 2, 3]; |
| let removed = arr.splice(1, 1); |
| console.log(arr); |
复制
数组连接
| let arr = [1, 2, 3]; |
| let newArr = arr.concat([4, 5]); |
| console.log(newArr); |
复制
返回找到的第一个匹配项的索引,如果没有找到则返回-1
| let arr = [1, 2, 3]; |
| let index = arr.indexOf(2); |
| console.log(index); |
复制
判断数组是否包含某个值,返回布尔值
| let arr = [1, 2, 3]; |
| let hasTwo = arr.includes(2); |
| console.log(hasTwo); |
复制
创建一个新数组,其结果是对原数组中的每个元素调用提供的函数后的返回值
| let arr = [ |
| { name: 'Alice', age: 25 }, |
| { name: 'Bob', age: 30 }, |
| { name: 'Charlie', age: 35 } |
| ]; |
| let names = arr.map(function(item) { |
| return item.name; |
| }); |
| console.log(names); |
复制
过滤、筛选
| let arr = [ |
| { name: 'Alice', age: 25 }, |
| { name: 'Bob', age: 30 }, |
| { name: 'Charlie', age: 35 } |
| ]; |
| let noBobArray = arr.filter((item) => item.name !== 'Bob'); |
| console.log(noBobArray); |
| |
| |
| |
| |
复制
查找元素
| var value = [1, 5, 10, 15].find((value, index)=> { |
| return value > 9; |
| }) |
| |
| var index = [1, 5, 10, 15].findIndex((value, index)=> { |
| return value > 9; |
| }) |
复制
slice() 提取不会修改原数组
| let fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"]; |
| let citrus = fruits.slice(1); |
| console.log(citrus); |
| |
| let citrusShort = fruits.slice(1, 3); |
| console.log(citrusShort); |
| |
| let citrusNegative = fruits.slice(-3, -1); |
| console.log(citrusNegative); |
复制
Object对象见操作
| 当然,以下是按照您提供的格式整理的关于操作JavaScript对象`person`的示例: |
| |
| ```javascript |
| var person = { |
| name: "Alice", |
| age: 25, |
| isStudent: true |
| }; |
| var person1={ |
| name:'Tom', |
| money:'2000元' |
| } |
| |
| //合并两个对象 |
| var person2 = Object.assign({}, person, person1); |
| /* |
| var person2 = { |
| name: "Tom", // 'Tom' 覆盖了 'Alice' |
| age: 25, // 来自于 person 对象 |
| isStudent: true, // 来自于 person 对象 |
| money: '2000元' // 来自于 person1 对象 |
| }; |
| |
| */ |
| // 访问属性 |
| console.log(person.name); // 输出: Alice |
| console.log(person['name']); // 输出: Alice |
| |
| // 修改属性 |
| person.age = 26; // 修改属性 |
| console.log(person.age); // 输出: 26 |
| |
| // 添加新属性 |
| person['money'] = 1000; // 添加一个属性 |
| console.log(person.money); // 输出: 1000 |
| |
| // 删除属性 |
| delete person.isStudent; // 删除一个属性 |
| console.log(person.isStudent); // 输出: undefined |
| |
| // 检测属性是否存在 |
| // 使用 in 运算符 |
| console.log("name" in person); // 输出: true |
| |
| // 使用 hasOwnProperty() 方法 |
| console.log(person.hasOwnProperty("name")); // 输出: true |
| |
| // 遍历对象属性使用 for...in 循环 |
| for (var key in person) { |
| console.log(key); // 输出: name, age, money |
| console.log(person[key]); // 输出: Alice, 26, 1000 |
| } |
| |
复制
jQuery简化DOM操作
| $('div'); |
| |
| $('.class'); |
| |
| $('.class'); |
| $('.class').parent(); |
| $('.class').parents(".parent"); |
| $('.class').closest(".parent"); |
| $('.class').siblings() |
| $('.class').siblings('selector') |
| $('.class').next() |
| $('.class').prev() |
| |
| $('.class').each(function(index, element){ |
| $(this) |
| $(element) |
| }) |
| var defult_obj = {a:1,b:2,c:3} |
| var new_obj = {d:4,e:5,f:6}; |
| |
| var merge_obj = $.extend(defult_obj, new_obj); |
| |
| |
| |
| var array = [1,2,3,4,5]; |
| $.each(array, function(i, value) { |
| this; |
| i; |
| value; |
| }); |
| |
| |
| var object = {a:1,b:2,c:3} |
| $.each(object, function(name, value) { |
| this; |
| name; |
| value; |
| }); |
| var html = $('div').html(); |
| |
| $('div').html('<p>New content</p>'); |
| |
| $('div').addClass('newClass'); |
| $('div').removeClass('oldClass'); |
| |
| $('div').attr('data-value'); |
| |
| $('img').attr('src'); |
| $('img').attr('src', 'newImage.jpg'); |
| |
| $('button').click(function() { |
| alert('Button clicked!'); |
| }); |
| $('button').on('click', function() { |
| alert('Button clicked!'); |
| }); |
| $('body').on('click','button', function() { |
| alert('Button clicked!'); |
| }); |
| |
| |
| $.ajax({ |
| url: '/test/demo', |
| success: function(result){ |
| $('#container').html(result); |
| } |
| }); |
| |
| $.get('/test/demo?a=1&b=2', function(res) { |
| console.log(res); |
| }); |
| |
| $.post('/test/demo', {name: 'John', time: '2pm'}, function(res) { |
| console.log(res); |
| }); |
| |
复制
Vue2 cdn模式 模板
vue2官网
vue2官网
ui框架官网 element ui
ui框架官网 element ui
| <!DOCTYPE html> |
| <html> |
| |
| <head> |
| <meta charset="UTF-8"> |
| <title>Vue2 cdn模式</title> |
| <link rel="stylesheet" href="https://assets.cdn.com/cdn_pkg/company-vue-element/company-vue-element.css"> |
| <script src="https://assets.cdn.com/js/jquery-1.8.3.min.js"></script> |
| <script src="https://assets.cdn.com/cdn_pkg/h5-vant/vue.min.js"></script> |
| <script src="https://assets.cdn.com/cdn_pkg/pc-vue-element/element.js"></script> |
| </head> |
| |
| <body> |
| <div id="app"> |
| <template> |
| <span>Message: {{ msg }}</span> |
| <div v-bind:id="dynamicId"></div> |
| <div :id="dynamicId"></div> |
| <a :href="link_url"></a> |
| <button @click="handleAdd()">添加数量</button> |
| <input v-model="addNum" :value="addNum"> |
| <img :src="img_url"> |
| <p v-if="isRender">现在你看到我了</p> |
| <p v-show="isShow">现在你看到我了</p> |
| |
| <button @click.stop="handleClick">1111</button> |
| |
| <ul id="example-1"> |
| <li v-for="item in items" :key="item.message"> |
| {{ item.message }} |
| </li> |
| </ul> |
| |
| |
| <div v-bind:class="{ 'active': isActive, 'disable': isDisable }" |
| :class="['container', errorClass, isDisable ? 'disable':'']"></div> |
| |
| |
| |
| <el-row> |
| <el-button>默认按钮</el-button> |
| <el-button type="primary">主要按钮</el-button> |
| <el-button type="success">成功按钮</el-button> |
| <el-button type="info">信息按钮</el-button> |
| <el-button type="warning">警告按钮</el-button> |
| <el-button type="danger">危险按钮</el-button> |
| </el-row> |
| <el-input-number v-model="num" @change="handleChange" :min="1" :max="10" label="描述文字"></el-input-number> |
| <el-date-picker v-model="dateValue1" type="date" placeholder="选择日期"> |
| </el-date-picker> |
| </template> |
| </div> |
| |
| <script> |
| const item = { |
| date: '2016-05-02', |
| name: '王小虎', |
| address: '上海市普陀区金沙江路 1518 弄' |
| }; |
| |
| var VueDom = new Vue({ |
| el: '#app', |
| |
| data() { |
| return { |
| msg: 'Hello World', |
| dynamicId: 1, |
| link_url: 'http://www.baidu.com', |
| img_url: '//assets.huibo.com/img/company/login/banner.png', |
| isRender: true, |
| isShow: true, |
| |
| addNum: 0, |
| |
| items: [ |
| { message: 'Foo' }, |
| { message: 'Bar' } |
| ], |
| |
| a_age: 1, |
| b_age: 2, |
| |
| isActive: true, |
| isDisable: false, |
| errorClass: 'error', |
| |
| num: 1, |
| dateValue1: '' |
| }; |
| }, |
| computed: { |
| total() { |
| return this.a_age + this.b_age; |
| } |
| }, |
| watch: { |
| total(val, old) { |
| console.log(val); |
| }, |
| }, |
| |
| created() { |
| }, |
| mounted() { |
| }, |
| |
| beforeDestroy() { |
| |
| }, |
| |
| destroyed() { |
| |
| }, |
| methods: { |
| navTo(name) { |
| window.location.href = `/${name}.html`; |
| }, |
| handleClick($event) { |
| console.log($event.target.innerText); |
| }, |
| handleAdd() { |
| this.addNum++; |
| }, |
| aNumAdd() { |
| this.a_age++; |
| }, |
| bNumAdd() { |
| this.b_age++; |
| }, |
| handleChange(value) { |
| console.log(value); |
| } |
| } |
| }); |
| </script> |
| </body> |
| </html> |
复制
php smart +html
| <div>{/$a/}</div> |
| |
| {/if $is_contact/} |
| <div>111</div> |
| {/else/} |
| <div>222</div> |
| {//if/} |
| |
| {/if !empty($resume_list)/} //判断不为空 |
| |
| {/foreach $resume_list as $k => $v/} |
| |
| <div data-val="{/$v['job_id']/}" class="{/if $k == 0/}first{//if/}"> |
| {/if $v['station']/}{/$v['station']/}{//if/} |
| </div> |
| |
| {//foreach/} |
| |
| {//if/} |
| <div data-val="6001" class="first">销售代表</div> |
| <div data-val="6002">人力资源</div> |
| <div data-val="6003">普工</div> |
复制
| |
| 注释代码 |
| |
| var account_id = '{/$account_id/}'; |
| |
| |
| var string = '{/$string/}'; |
| |
| |
| var number = {/if $number/}{/$number/}{/else/}0{ |
| var array = {/if !empty($array)/}{/$array/}{/else/}[]{ |
| |
| |
| |
| var a = {/$a/} |
| |
| {/$a=2/} |
| |
| |
| {/if $is_contact/} |
| 11 |
| { |
| |
| |
| {/if $is_contact/} |
| 22 |
| {/else/} |
| 33 |
| { |
| |
| |
| |
| {/if !empty($resume_list)/} |
| {/foreach $resume_list as $k => $v/} |
| |
| <div class="{/if $k == 0/}first{ |
| {/if $v['station']/}{/$v['station']/}{ |
| </div> |
| |
| { |
| |
| { |
| |
| |
| |
| |
| var allJobList = [ |
| {job_id:'',station:'全部职位'}, |
| {/if !empty($job_list)/} |
| {/foreach $job_list as $key=>$val/} |
| { |
| job_id: '{/$val['job_id']/}', |
| station: '{/$val['station']/}' |
| }, |
| { |
| { |
| ]; |
| |
| |
| {job_id:'', station:'全部职位'}, |
| {job_id: '204',station: '销售代表'}, |
| {job_id: '205',station: '人力资源'}, |
| ] |
| |
| |
| |
| var salaryItems = [{value: '0', label: '期望月薪不限'}]; |
| {/foreach $salaries as $key => $value/} |
| salaryItems.push({value: '{/$key/}', label: '{/$value/}'}); |
| { |
| |
| var salaryItems = [{value: '0', label: '期望月薪不限'}]; |
| salaryItems.push({value: '1', label: '2000'}); |
| salaryItems.push({value: '2', label: '3000'}); |
| salaryItems.push({value: '3', label: '4000'}); |
| |
| |
| {/include file="chat/chat.html"/} |
| |
复制
jq ajax 使用es6 Promise封装请求
| window.$http={ |
| post:function(url, params, options){ |
| return new Promise((resolve, reject) => { |
| window.$http.ajax(url, params, 'POST').then(res=>{ |
| resolve(res); |
| }).catch(err=>{ |
| reject(err); |
| }) |
| }); |
| }, |
| get:function(url,options){ |
| return new Promise((resolve, reject) => { |
| window.$http.ajax(url, {}, 'GET').then(res=>{ |
| resolve(res); |
| }).catch(err=>{ |
| reject(err); |
| }) |
| }); |
| }, |
| |
| ajax:function(url, params, method, options){ |
| return new Promise((resolve, reject) => { |
| $.ajax({ |
| type: method || 'POST', |
| url: url, |
| data: params, |
| async: true, |
| dataType:'json', |
| headers: { |
| }, |
| ...options, |
| success: function(res){ |
| |
| if(res.isNeedLogin){ |
| window.location.reload(); |
| reject(); |
| return; |
| } |
| if(res.status || (!res.status && res.code==200)){ |
| resolve(res); |
| return; |
| } |
| |
| if ([40002].includes(res.code)) { |
| console.log(res.code); |
| reject(res); |
| return false; |
| } |
| if ([40003,40004,40005].includes(res.code)) { |
| $.anchorMsg(res.msg); |
| reject(res); |
| return false; |
| } |
| reject(res); |
| }, |
| error: function(xhr, textStatus, errorThrown) { |
| |
| if (textStatus === 'timeout') { |
| |
| $.anchorMsg('请求超时,请检查网络连接'); |
| console.log('请求超时,请检查网络连接'); |
| } else if (xhr.status === 0) { |
| |
| |
| console.error('网络连接失败,请检查网络或跨域设置'); |
| } else if (xhr.statusText == "parsererror" && xhr.responseText) { |
| document.documentElement.innerHTML = xhr.responseText; |
| }else { |
| |
| |
| console.error('发生错误:' + errorThrown); |
| } |
| reject(errorThrown); |
| } |
| }); |
| }); |
| }, |
| } |
复制