无法访问另一个CoffeeScript文件中的函数?

问题描述 投票:0回答:1

我需要将src中的图像的background.coffee设置为另一页,但是当我从backround.coffee调用该函数时,我得到了view.setScreenshotUrl is not a function

//background.coffee
views = chrome.extension.getViews()
for view in views
    if view.location.href is viewTabUrl
        view.setScreenshotUrl screenshotUrl
        break

//page.coffee
setScreenshotUrl = (url) -> 
    document.getElementById("target").src = url
google-chrome-extension coffeescript
1个回答
1
投票

我将该函数添加到窗口对象中:

window.setScreenshotUrl = (url) -> 
    document.getElementById("target").src = url
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.