Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

演示文档使用 require 调用 #1111

Closed
afc163 opened this issue Dec 24, 2014 · 8 comments
Closed

演示文档使用 require 调用 #1111

afc163 opened this issue Dec 24, 2014 · 8 comments
Assignees
Labels

Comments

@afc163
Copy link
Member

afc163 commented Dec 24, 2014

目前在演示中是用 seajs.use 来调用。页面会自动插入代码进行运行和展示。

seajs.use('module', function(module) {
  // use module
});

对 seajs 进行弱化后,应该推荐用 require 来调用 CommonJS 模块。因此希望演示文档可以这么写:

var module = require('file');
// use module

同样会自动插入执行和展示演示代码。

@sorrycc
Copy link
Member

sorrycc commented Dec 24, 2014

+1

@afc163 afc163 added the feature label Dec 24, 2014
@yiminghe
Copy link

+2

@hotoo
Copy link
Member

hotoo commented Dec 24, 2014

+3

@afc163 afc163 self-assigned this Dec 24, 2014
@sorrycc
Copy link
Member

sorrycc commented Dec 24, 2014

@afc163 我搞得差不多了,把 jsx 和这个一起搞了。

@afc163 afc163 closed this as completed in 3c57c44 Dec 24, 2014
@afc163
Copy link
Member Author

afc163 commented Dec 24, 2014

完成了。http://spmjs.io/docs/arale-dialog/examples/

简单包裹了不含 seajs.use 的代码(向下兼容),并用 seajs.use 立刻进行调用。

唯一的问题是 ````iframe 里的代码没有进行处理。因为 iframe 里如果这么显示感觉怪怪的:

<link href="../src/dialog.css" rel="stylesheet">
<input type="button" id="trigger1" value="默认样式对话框" />

<script>
var ConfirmBox = require('dialog').ConfirmBox;
var cb = new ConfirmBox({
    trigger: '#trigger1',
    title: '我真是标题啊',
    message: '我是内容 我是内容',
    onConfirm: function() {
        var that = this;
        this.set('title', '三秒后关闭对话框');
        this.set('message', '不要啊!!');
        setTimeout(function() {
            that.hide();
        }, 3000);
    }
});
</script>

@afc163
Copy link
Member Author

afc163 commented Dec 24, 2014

擦,刚看到 @sorrycc 的回复。

@shaoshuai0102
Copy link

nice try

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants