【发布时间】:2016-10-13 00:09:42
【问题描述】:
【问题讨论】:
-
就用它?不过,浏览器需要支持 ES6 生成器功能。如果没有,则需要使用转译器。
标签: javascript client-side coroutine co
【问题讨论】:
标签: javascript client-side coroutine co
只是为了测试。请勿在生产中使用。
(function () {
$.ajax({
type: 'GET',
url: 'https://raw.githubusercontent.com/tj/co/master/index.js',
async: false,
}).done(function (source) {
var module = {exports: {}};
var exports = module.exports;
eval(source); // run the source of co
window.co = module.exports; // bind co to window
console.log(window.co);
}).fail(function (xhr, textStatus, statusText) {
console.log(textStatus, statusText);
})
})();
【讨论】:
当然可以,你需要转译你的代码(使用 babel 和 regenerator plugin ),它工作正常!
【讨论】: