litian
2024-05-23 cc26637f18b8ed178420122d7335b3f89be92ada
src/views/components/dictionary.vue
@@ -60,16 +60,25 @@
import { ref, reactive, watch, onMounted, inject } from 'vue'
const request = inject('request')
const props = defineProps({
  searchCon: Boolean
  searchCon: String
})
const searchContent = ref('')
const isFull = ref(false)
watch(props, (newValue) => {
  // 统监听props的值变化,动态修改isShow的值
  searchContent.value = newValue.searchCon
  getSearchResult()
})
onMounted(() => {
  if(props){
    searchContent.value = props.searchCon
    getSearchResult()
  }
})
const searchResult = ref([])
const getSearchResult = () => {
  if (searchContent.value) {
@@ -81,8 +90,6 @@
        isFull: isFull.value
      }
    }).then((res) => {
      console.log(JSON.parse(res[0].sentence)[0].sCn)
      // encodeURIComponent(res[0].syno[0].tran)
      if (res.length > 0) {
        res.map((item) => {
          item.phrase = JSON.parse(item.phrase)