1.0.0 • Published 4 years ago

mars-native-components v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Native Components

安装

$ npm i mars-native-components

使用

// 低版本浏览器不支持 customElements, 需要引入 polyfill
import '@webcomponents/webcomponentsjs/bundles/webcomponents-ce';
import { NativeImage, NativeVideo } from 'mars-native-components';
// 声明 native 组件
window.customElements.define('native-image', NativeImage);
window.customElements.define('native-video', NativeVideo);

组件列表

native-image

属性

  • src: 图片地址,支持 png、jpg、gif、webp、heic、awebp 等格式

事件

  • load: 图片加载完成, 加载完成后可以从 native-image 获取真实大小
  • error: 图片加载出错

使用示例

<native-image src="http://p1.toutiaoimg.com/origin/pgc-image/15372517133209ed591065c">
</native-image>

CHANGELOG