我正在制作一个与故事博客,vue和nuxt网站。在我的组件中,我试图通过从storyblok中获取一个值并在我的对象中获得正确的HEX代码来改变组件的背景色。然而,我似乎找不到出了什么问题,我得到了这个错误。
TypeError: Cannot read property 'color1' of undefined
at VueComponent.backgroundColor (app.js:6239)
at Watcher.get (commons.app.js:25459)
at Watcher.evaluate (commons.app.js:25564)
at Vue
我尝试通过执行以下操作将参数传递给mongodb脚本:
mongo --eval="foo='hello world'" test.js
但我希望变量foo是可选的(即,如果存在则使用foo,否则不使用它继续),因此在test.js中,我测试了该变量的存在:
if (foo)
print(foo)
//do stuff with foo
如果我没有在命令行中指定foo,这将抛出一个错误:
$ mongo test.js
ReferenceError: foo is not defined test.js:1
failed to load: tes
我有一个html页面。
加载文件script.js
function myFunction() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'http://demodomain.com/script.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefor
为什么我要在javascript文件中获得Uncaught ReferenceError: i is not defined?
所以我就是这么做的。
app.js
$(function() {
var i = 1;
});
some.js
$(function() {
alert(i);
});
这是我如何排序我的文件。
// included jquery here
<script src="/app.js" type="javascript/text"></script>
<script src="/some.j