我想将外部图像(从另一个网址)的宽度设置为变量,因此我可以在另一个函数上使用新分配的变量。
问题是我在变量上收到{{#if userAdmin}} //Here the context is not available within the buttons.hbs
<input type='submit' class='actionbuttons' id='newMessageButton' name='{{properties.replyURL}}' value='{{i18n "+ New Message"}}' />
{{/if}}
消息,请参阅下面的代码。
undefined
我做错了什么,我该怎么办?
答案 0 :(得分:0)
使用异步函数时,需要将其余代码放在回调函数中(或使用promises)。在这里,您需要将alert
置于回调中。
var a = getMeta(site_url, function(width, height) {
alert(width);
});