替换v-model API 为 defineModel
This commit is contained in:
@@ -1,36 +1,35 @@
|
||||
<template>
|
||||
<vue-office-docx :src="docx" @rendered="rendered">
|
||||
|
||||
</vue-office-docx>
|
||||
<vue-office-docx
|
||||
:src="docx"
|
||||
@rendered="rendered"
|
||||
/>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: "Docx"
|
||||
name: 'Docx'
|
||||
}
|
||||
</script>
|
||||
<script setup>
|
||||
import {ref, watch} from 'vue'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
// 引入VueOfficeDocx组件
|
||||
import VueOfficeDocx from '@vue-office/docx'
|
||||
// 引入相关样式
|
||||
import '@vue-office/docx/lib/index.css'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: () => ""
|
||||
}
|
||||
const model = defineModel({
|
||||
type: String,
|
||||
})
|
||||
|
||||
const docx = ref(null)
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
value => docx.value = value,
|
||||
{immediate: true}
|
||||
() => model,
|
||||
value => { docx.value = value },
|
||||
{ immediate: true }
|
||||
)
|
||||
const rendered = () => {
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -33,16 +33,12 @@ import Excel from '@/components/office/excel.vue'
|
||||
|
||||
const path = ref(import.meta.env.VITE_BASE_API)
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: () => ''
|
||||
}
|
||||
})
|
||||
const model = defineModel({ type: String})
|
||||
|
||||
const fileUrl = ref('')
|
||||
const ext = ref('')
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
() => model,
|
||||
val => {
|
||||
fileUrl.value = val
|
||||
const fileExt = val.split('.')[1] || ''
|
||||
|
||||
Reference in New Issue
Block a user