javascript - 为什么在 Vue.js 中使用 `var` 关键字?
问题描述
我在学习框架时看到的每个教程和代码片段都var
用于它们的声明,包括官方文档。
前言,我刚开始学习Vue,所以对它了解的很少,但还没有找到答案。
与其他假设属性名称相同:
new Vue({
data: data
})
对比
new Vue({
data
})
假设 ES6应该是标准的const
,我错了吗?let
有理由使用var
Vue.js 吗?ES6 有问题吗?
解决方案
Why do the docs use var
and avoid ES6 features? I'd say to support lowest common denominator, ie, worst browser.
Since Vue can be included as a plain old <script>
tag (UMD / global, no build system) and supports all ES5-compliant browsers (IE9+), they keep the documentation consistent.
Use whatever you...
- Feel comfortable using, and
- Is supported by the target production environment
- your build system (if you're using one) can help transpile ES6 code to a lower language level
推荐阅读
- amazon-web-services - 每天自动启动 EC2 的最简单方法
- docker - 如何构建 docker engine arm 二进制文件?
- android - 将数据从 Activity 传递到 Fragment 没有显示任何内容
- python - 响应 Cookie 未在 CORS 烧瓶中设置
- java - CMD - 未找到 Java 包
- jquery - 如何使用 jquery each 方法将 html 元素添加到 html 集合的每个元素?
- javascript - 在 Javascript 中删除 HTML5 元素的动画
- c# - 如果 C# DateTime 变量为空,则读取 csv 文件如何返回字符串消息
- hadoop - Cube.js 作为报告工具
- c++ - 这个函数调用“delay+(1000)”在语法上是否正确?