<template> <!-- 模板内容 --> </template>
<script>
export default {
data() {
return {
count: 0, // 用于响应式数据
};
},
methods: {
exampleMethod() {
var varVariable = 'I am a var variable'; // 函数作用域
let letVariable = 'I am a let variable'; // 块级作用域
const constVariable = 'I am a const variable'; // 块级作用域,不可重新赋值
if (true) {
var varVariable = 'Var can be re-declared';
let letVariable = 'Let cannot be accessed before it is declared';
// constVariable = 'This would cause an error'; // 不能对常量constVariable重新赋值
}
console.log(varVariable); // 输出: 'Var can be re-declared'
console.log(letVariable); // 输出: 'I am a let variable'
// 使用letVariable在这里会得到块外letVariable的值,因为它们是两个不同的变量。
}
}
}
</script>
标签:const,letVariable,am,variable,let,var From: https://www.cnblogs.com/wuyunna/p/18077867