【发布时间】:2015-08-24 05:12:10
【问题描述】:
我是 coffeescript 的新手。在包含我的咖啡脚本文件functions.coffee 后,会生成以下文件main.js:
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
require('../../modules/common/frontend/functions');
},{"../../modules/common/frontend/functions":2}],2:[function(require,module,exports){
//Link selection in menu
function setCurrentlink(){
var currenturl=window.location.href;
var part=currenturl.match(/\n\/displaywizard\/(.*)$/g);
alert(part);
}
...
},{}]},{},[1])
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2sv...
我一直试图从 html 文件中调用函数 setCurrentlink 为:
<script type="text/javascript">setCurrentlink();</script>
我尝试将指向 js 文件的链接放在页面底部的 head 部分,但我收到一条错误消息,提示“找不到变量 setCurrentlink”。请帮我找出我的错误或我遗漏的任何东西。
functions.coffee
#@export functions
#Link selection in menu
setCurrentlink = ->
currenturl = window.location.href
part = currenturl.match(/\n\/displaywizard\/(.*)$/g)
alert currenturl
return
...
【问题讨论】: