优化部分代码

This commit is contained in:
zhouliujun 2019-11-14 11:11:38 +08:00
parent b2109016de
commit 21261846f1
3 changed files with 9 additions and 17 deletions

View File

@ -1,8 +1,7 @@
<template>
<div id="app">
<vue-aliplayer-v2 ref="VueAliplayerV2" id="player-1194076936807170050" :options="{source:'rtmp://182.145.195.238:1935/hls/1194076936807170050'}" />
<vue-aliplayer-v2 ref="VueAliplayerV2" id="player-1194076936807170050" :options="{source:'rtmp://182.145.195.238:1935/hls/1194076936807170053'}" />
<vue-aliplayer-v2 ref="VueAliplayerV2" id="player-1194076936807170051" :options="{source:'rtmp://182.145.195.238:1935/hls/1194076936807170051'}" />
<vue-aliplayer-v2 ref="VueAliplayerV2" id="player-1194076936807170052" :options="{source:'rtmp://182.145.195.238:1935/hls/1194076936807170052'}" />
<button @click="play()">播放</button>
<button @click="pause()">暂停</button>
<button @click="replay()">重播</button>
@ -14,10 +13,6 @@ export default {
data(){
return {
value: null,
options:{
isSign: true, // [Boolean] ,线, true线
isShowBorder: false, // []
},
player: null
}
},

View File

@ -1,7 +1,7 @@
// 导入组件,组件必须声明 name
import AliplayerV2 from './src/main.vue';
import VueAliplayerV2 from './src/main.vue';
// 为组件添加 install 方法,用于按需引入
AliplayerV2.install = function (Vue) {
Vue.component(AliplayerV2.name, AliplayerV2);
VueAliplayerV2.install = function (Vue) {
Vue.component(VueAliplayerV2.name, VueAliplayerV2);
}
export default AliplayerV2;
export default VueAliplayerV2;

View File

@ -1,10 +1,10 @@
// packages / index.js
// 导入单个组件
import AliplayerV2 from './AliplayerV2';
import VueAliplayerV2 from './AliplayerV2';
// 以数组的结构保存组件,便于遍历
const components = [
AliplayerV2
VueAliplayerV2
];
// 定义 install 方法
@ -13,18 +13,15 @@ const install = (Vue) =>{
install.installed = true;
// 遍历并注册全局组件
components.map(component => {
Vue.component(component.name, component)
return Vue.component(component.name, component)
});
};
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue);
}
export default {
// 导出的对象必须具备一个 install 方法
install,
AliplayerV2,
VueAliplayerV2
// 组件列表
...components
};