| | |
| | | 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) { |
| | |
| | | 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) |