//此代码在script.js文件中
var E_c = (function () {
var etagCookieName = 'ecn';
var cacheCookieName = 'ccn';
this._class = function () {
this.set = function (name, value) {
alert(name);
alert(value);
}
};
return this._class;});在另一个文件中,我创建了E_c对象,但如果我尝试使用ec.set()调用set方法,则会生成错误ec.set()不是function.please指南,这是我出错的地方。以下是我的代码
<script type="text/javascript">
function create_cookie() {
var ec = new E_c();
ec.set("id","567") ;
}
create_cookie();
发布于 2016-06-28 15:28:48
var E_c = (function () {
var etagCookieName = 'ecn';
var cacheCookieName = 'ccn';
this._class = function () {
this.set = function (name, value) {
alert(name);
alert(value);
}
};
return this._class;}()); // <-- () to execute the anonymous functionshttps://stackoverflow.com/questions/38068873
复制相似问题