mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-28 18:41:20 -08:00
Update README.md
This commit is contained in:
1 parent
6370f607f8
commit
b36f88db5f
1 file changed
-63
@@ -98,69 +98,6 @@ let art = new Artplayer({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## React
|
|
||||||
|
|
||||||
```jsx
|
|
||||||
import Artplayer from 'artplayer'
|
|
||||||
import { useEffect, useRef } from 'react'
|
|
||||||
|
|
||||||
export default function Player({ option, getInstance, ...rest }) {
|
|
||||||
const $container = useRef()
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const art = new Artplayer({
|
|
||||||
...option,
|
|
||||||
container: $container.current,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (typeof getInstance === 'function') {
|
|
||||||
getInstance(art)
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => art.destroy(false)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
return <div ref={$container} {...rest}></div>
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Vue
|
|
||||||
|
|
||||||
```vue
|
|
||||||
<template>
|
|
||||||
<div ref="$container" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import Artplayer from 'artplayer'
|
|
||||||
import { onBeforeUnmount, onMounted, ref, shallowRef } from 'vue'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
option: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const emit = defineEmits(['getInstance'])
|
|
||||||
|
|
||||||
const art = shallowRef(null)
|
|
||||||
const $container = ref(null)
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
art.value = new Artplayer({
|
|
||||||
...props.option,
|
|
||||||
container: $container.value,
|
|
||||||
})
|
|
||||||
emit('getInstance', art.value)
|
|
||||||
})
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
art.value.destroy(false)
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
|
|
||||||
| Name | Describe | State |
|
| Name | Describe | State |
|
||||||
|
|||||||
Reference in new issue
Block a user