当前位置:网站首页>【let var const】
【let var const】
2022-07-01 18:45:00 【礼礼。】
块级作用域
let和const有块级作用域,var没有
let和const在同一作用域中都不可以重复说明,var可以
推荐使用let
var i=99;
for(let i=0; i<5; i++){
//在此处不可以用var进行变量声明,要用let声明,因为let有块级作用域的功能
//如果使用的是var声明,那么打印出的结果 全局的i将会被影响,输出的就不再是99
console.log(i); //输出结果: 0 1 2 3 4
}
console.log(i); //输出结果: 99
JS文件引入方法:新建aa.js文件,在html文件中引入
<script src="aa.js"></script>
var会直接改变window对象,是不合理的,当声明的变量与window变量正好一样是,就会覆盖window变量,让其不能正常操作显示
var web = "hdcms";
console.log(window.web); // 此时打印输出的就是hdcms,var声明的变量改变了全局的变量,是不合理的
let 不会直接改变window对象,当声明的变量与window变量正好一样是,不会覆盖window变量,更推荐使用
let web = "hdcms";
console.log(window.web); // 此时打印输出的就是undefine,let声明的变量不会改变全局变量
传值:
let a = 1;
let b = a;
console.log(a,b); //1,1
传址
let e = { name="a" };
let f = e;
console.log(e,f); // { name="a"} { name="a" }
f.name = "123”;
console.log(e,f); // { name="123"} { name="123" }
null和undefined
函数没有返回值,参数没有传值,声明了没有赋值, 即 没有值就是undefined
后台管理系统:是基于Vue和elementui实现的,使用了最新的前端技术栈,内置i18n国际化解决方案,动态路由,权限验证,提炼了典型的业务模型,提供了丰富的功能组件
动态路由:左侧导航栏,面包屑、
index.jsion 文件:children的子路由(id、层次、子路由名称、路径),一层包一层
Vue文件: router
面包屑:
<el-breadcrumb-item
:to="{path:'/'}"
v-for="item in breadcrumbList"
:key="item.path"
>
{
{
item.meta.title}}
</el-breadcrumb-item >
<router-view></router-view>
......
computed{
breadcrumbList(){
return this.$route.matched
}
}
v-for 循环 ,且点击触发
<div
v-for="item in list"
:key="item.title"
>
{
{
item.title}}
</div>
return{
list:[
{
title:'A'},
{
title:'B'},
{
title:'C'},
{
title:'D'}
]
}
methods:{
handClick({
title}){
switch(title){
case 'A':
console.log('我是A');
break
case 'B':
console.log('我是B');
break
case 'C':
console.log('我是C');
break
case 'D':
console.log('我是D');
break
}
}
}
插值表达式: { { flag ? ‘yes’ : ‘no’ }} data里定义flag默认为false
watch 监听属性
什么是回调函数?
递归?
关键字this?
箭头函数?简化写法
闭包?子函数访问父函数
防抖。节流
边栏推荐
- Native JS creates a calendar - supports mouse wheel scrolling to select months - and can be ported to any framework
- [to.Net] C set class source code analysis
- 【英语语法】Unit1 冠词、名词、代词和数词
- 【sql优化】with as 和 临时表的区别
- Case sharing: basic networking configuration of QinQ
- Live HLS protocol
- pickle. Load error [attributeerror: can't get attribute 'volatile' on < module '\u main']
- Contos 7 set up SFTP to create users, user groups, and delete users
- Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference
- [info() method in org.slf4j.logger]
猜你喜欢
随机推荐
[go ~ 0 to 1] day 5 July 1 type alias, custom type, interface, package and initialization function
P2433 【深基1-2】小学数学 N 合一
下载(导出)pdf模板文件(比如:审批单),报错:Invalid nested tag *** found, expected closing tag ***
Interview questions for audio and video positions in Dachang -- today's headline
EasyGBS网络不稳定情况下重复请求视频拉流问题的优化
赋能「新型中国企业」,SAP Process Automation 落地中国
ddr4测试-2
Use the uni app demo provided by Huanxin to quickly realize one-on-one chat
对象的创建
How to solve the problem of splash screen when the main and sub code streams of easygbs are h.265?
118. 杨辉三角
ffmpeg 音频相关命令
Analysis of GetMessage underlying mechanism
The use of subplot function in MATLAB
Enabling "new Chinese enterprises", SAP process automation landing in China
宝,运维100+服务器很头疼怎么办?用行云管家!
brpc理解
nacos启动失败问题解决与总结
The key to the success of digital transformation enterprises is to create value with data
Interview question 16.16 Partial sorting - Double finger needling