vue使用axios调取数据

<script setup lang="ts">
import { ref,reactive} from 'vue';
import axios from 'axios'

const obj = reactive({
  codes: []
})

const total = ref(0)
const page = ref(1)
const lang = ref("psql")

const onSearch = (val:string) => {
   Toast(lang.value);
   axios.get('/Search?search='+val+'&lang='+lang.value).then(function (response) {
     let data = response.data;
     obj.codes = data.data;
     page.value = 1;
     total.value = data.total;
  }).catch(function (error) {
    console.log(error);
  });
}
</script>

<template>

<van-search
  v-model="value"
  shape="round"
  background="#4fc08d"
  placeholder="请输入搜索关键词"
  @search="onSearch"
>
  <template #action>
    <div @click="onClickButton">搜索</div>
  </template>
</van-search>

</template>

<style scoped>

</style>
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!