Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[platform] 五发大连排 提交组件改动:mip-jiangfeng-LoadingJs #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions mip-jiangfeng-LoadingJs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# mip-jiangfeng-LoadingJs

mip-jiangfeng-LoadingJs 给网页加载两个必须的js

标题|内容
----|----
类型|通用
支持布局|responsive,fixed-height,fill,container,fixed
所需脚本|https://c.mipcdn.com/static/v1/mip-jiangfeng-LoadingJs/mip-jiangfeng-LoadingJs.js

## 示例

### 基本用法
```html
<mip-jiangfeng-LoadingJs url1="/first.js" url2="/second.js">
引入所需的两个文件
</mip-jiangfeng-LoadingJs>
```

## 属性

### url1

说明:{加载的第一个js的路径}
必选项:{是}
类型:{字符串}
取值范围:{无}
单位:{单位}
默认值:{/beiyong.js}

### url2

说明:{加载的第二个js的路径}
必选项:{是}
类型:{字符串}
取值范围:{无}
单位:{单位}
默认值:{/pdtiao.js}

## 注意事项
在head内添加


30 changes: 30 additions & 0 deletions mip-jiangfeng-LoadingJs/mip-jiangfeng-LoadingJs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @file mip-jiangfeng-LoadingJs 组件
* @author
*/

define(function (require) {
'use strict';

var customElement = require('customElement').create();

/**
* 第一次进入可视区回调,只会执行一次
*/
customElement.prototype.firstInviewCallback = function () {
var element = this.element;
var sNewFirst = document.createElement('script');
var sNewSencond = document.createElement('script');
sNewFirst.async = true;
sNewSencond.async = true;
sNewFirst.src = element.getAttribute('url1');
sNewSencond.src = element.getAttribute('url2');
var s0 = document.getElementsByTagName('script')[0];
var s1 = document.getElementsByTagName('script')[1];
s0.parentNode.insertBefore(sNewFirst, s0);
s1.parentNode.insertBefore(sNewSencond, s1);
// TODO
};

return customElement;
});
7 changes: 7 additions & 0 deletions mip-jiangfeng-LoadingJs/mip-jiangfeng-LoadingJs.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @file mip-jiangfeng-LoadingJs样式文件
*/

mip-jiangfeng-LoadingJs {
// TODO
}
15 changes: 15 additions & 0 deletions mip-jiangfeng-LoadingJs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "mip-jiangfeng-LoadingJs",
"version": "1.0.0",
"description": "在头部加载两个js文件",
"contributors": [
{
"name": "jiangfeng",
"email": "[email protected]"
}
],
"engines": {
"mip": ">=1.1.0"
}
}