-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 重构 Vue 官方组件到 CustomElement (#614)
- Loading branch information
Showing
47 changed files
with
2,673 additions
and
12,344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
{ | ||
"list": [{ | ||
"key": "热门", | ||
"cities": [ | ||
{ | ||
"city": "北京", | ||
"pinyin": "beijing", | ||
"code": "1" | ||
}, | ||
{ | ||
"city": "上海", | ||
"pinyin": "shanghai", | ||
"code": "2" | ||
}, | ||
{ | ||
"city": "广州", | ||
"pinyin": "guangzhou", | ||
"code": "3" | ||
}, | ||
{ | ||
"city": "深圳", | ||
"pinyin": "shenzhen", | ||
"code": "4" | ||
}, | ||
{ | ||
"city": "重庆", | ||
"pinyin": "chongqing", | ||
"code": "5" | ||
} | ||
] | ||
}, { | ||
"key": "A", | ||
"cities": [ | ||
{ | ||
"city": "澳门", | ||
"pinyin": "aomen", | ||
"code": "7" | ||
}, | ||
{ | ||
"city": "安庆", | ||
"pinyin": "anqing", | ||
"code": "8" | ||
}, | ||
{ | ||
"city": "安泽", | ||
"pinyin": "anze", | ||
"code": "9" | ||
} | ||
] | ||
}, { | ||
"key": "B", | ||
"cities": [ | ||
{ | ||
"city": "宝清", | ||
"pinyin": "baoqing", | ||
"code": "10" | ||
}, | ||
{ | ||
"city": "宝鸡", | ||
"pinyin": "baoji", | ||
"code": "11" | ||
}, | ||
{ | ||
"city": "巴东", | ||
"pinyin": "badong", | ||
"code": "12" | ||
} | ||
] | ||
}, { | ||
"key": "C", | ||
"cities": [ | ||
{ | ||
"city": "重庆", | ||
"pinyin": "chongqing", | ||
"code": "13" | ||
}, | ||
{ | ||
"city": "成都", | ||
"pinyin": "chengdu", | ||
"code": "14" | ||
}, | ||
{ | ||
"city": "苍山", | ||
"pinyin": "cangshan", | ||
"code": "15" | ||
} | ||
] | ||
}, { | ||
"key": "D", | ||
"cities": [ | ||
{ | ||
"city": "大庆", | ||
"pinyin": "daqing", | ||
"code": "16" | ||
}, | ||
{ | ||
"city": "大理", | ||
"pinyin": "dali", | ||
"code": "17" | ||
}, | ||
{ | ||
"city": "东莞", | ||
"pinyin": "dongguan", | ||
"code": "18" | ||
} | ||
] | ||
}, { | ||
"key": "E", | ||
"cities": [ | ||
{ | ||
"city": "鄂尔多斯", | ||
"pinyin": "eerduosi", | ||
"code": "19" | ||
}, | ||
{ | ||
"city": "峨眉山", | ||
"pinyin": "emeishan", | ||
"code": "20" | ||
} | ||
] | ||
}, { | ||
"key": "F", | ||
"cities": [ | ||
{ | ||
"city": "阜阳", | ||
"pinyin": "fuyang", | ||
"code": "21" | ||
}, | ||
{ | ||
"city": "福州", | ||
"pinyin": "fuzhou", | ||
"code": "22" | ||
}, | ||
{ | ||
"city": "防城港", | ||
"pinyin": "fangchenggang", | ||
"code": "23" | ||
} | ||
] | ||
}, | ||
{ | ||
"key": "G", | ||
"cities": [ | ||
{ | ||
"city": "广州", | ||
"pinyin": "guangzhou", | ||
"code": "24" | ||
}, | ||
{ | ||
"city": "贵阳", | ||
"pinyin": "guiyang", | ||
"code": "25" | ||
} | ||
] | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
components/mip-city-selection/example/mip-city-selection-src-data.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html mip> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> | ||
<title>MIP page</title> | ||
<link rel="canonical" href="对应的原页面地址"> | ||
<link rel="stylesheet" href="https://c.mipcdn.com/static/v2/mip.css"> | ||
<style mip-custom> | ||
/* 自定义样式 */ | ||
|
||
</style> | ||
</head> | ||
|
||
<body> | ||
<!-- 测试组件,模拟异步 --> | ||
<mip-test id="cityTest"></mip-test> | ||
<mip-city-selection | ||
class="mip-hidden" | ||
on="citySelected:cityTest.print" | ||
data-src="./data.json"> | ||
</mip-city-selection> | ||
<script src="https://c.mipcdn.com/static/v2/mip.js"></script> | ||
<script src="/mip-city-selection/mip-city-selection.js"></script> | ||
<script src="./mip-test.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @file 测试组件 | ||
* @author mj([email protected]) | ||
*/ | ||
|
||
/* globals MIP */ | ||
|
||
class MIPTest extends MIP.CustomElement { | ||
build () { | ||
this.addEventAction('print', data => { | ||
this.print(data) | ||
}) | ||
} | ||
|
||
/** | ||
* 打印的测试内容 | ||
* | ||
* @param {any} content 打印的内容 | ||
*/ | ||
print (content) { | ||
if (typeof content === 'object') { | ||
content = JSON.stringify(content, null, 2) | ||
} | ||
|
||
this.element.innerHTML = '<code><pre>' + content + '</pre></code>' | ||
} | ||
} | ||
|
||
MIP.registerElement('mip-test', MIPTest) |
Oops, something went wrong.