[英]Uncaught SyntaxError: Unexpected strict mode reserved word Vue.js
I have a Vue instance我有一个 Vue 实例
var interface = new Vue(
{...}
)
And i created a class called MyCustomTooltip我创建了一个名为 MyCustomTooltip 的 class
class MyCustomTooltip {
constructor(array_info,vue_instance) {
this.tooltip_info = array_info;
this.vue_instance = vue_instance
console.log(interface)
}
}
I try to use 'interface' instance inside some methods in MyCustomTooltip class, but when i reference it I get Uncaught SyntaxError: Unexpected strict mode reserved word
.我尝试在 MyCustomTooltip class 的某些方法中使用“接口”实例,但是当我引用它时,我得到Uncaught SyntaxError: Unexpected strict mode reserved word
。 I fixed the issue by passing the vue instance to the constructor, but now i have to send the interface
variable every time i create a new MyCustomTooltip instance.我通过将 vue 实例传递给构造函数来解决了这个问题,但是现在我每次创建新的 MyCustomTooltip 实例时都必须发送interface
变量。
Does anyone know why is this happenning?有谁知道为什么会这样? How can i fix this?我怎样才能解决这个问题? Am i taking the wrong approach?我采取了错误的方法吗?
Are you using TypeScript?您使用的是 TypeScript 吗? If so, interface
is a reserved keyword used for declaring an interface https://www.typescriptlang.org/docs/handbook/interfaces.html如果是这样, interface
是用于声明接口https://www.typescriptlang.org/docs/handbook/interfaces.html的保留关键字
A simple fix would be to give your variable a different name.一个简单的解决方法是给你的变量一个不同的名字。 Even something as simple as changing it to myInterface
should solve the problem.即使像将其更改为myInterface
这样简单的事情也应该可以解决问题。
If you are not using TypeScript though, the error you're seeing is unexpected.但是,如果您没有使用 TypeScript,那么您看到的错误是意料之外的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.