vue如何实现select下拉框异步传值

758 ℃

vue开发中如何实现select下拉框异步传值,下面web建站小编给大家简单介绍一下!

具体代码如下:

<template>
  <select v-model="selectValue">
    <option v-for="(item,index) in selectOptions" :value="item.id">{{ item.name }}</option>
  </select>
</template>
 
<script>
import axios from "axios";
 
export default {
  data() {
    return {
      selectValue: null,
      selectOptions: []
    };
  },
  mounted() {
    axios
      .get("http://example.com/test")
      .then(res => {
        this.selectOptions = res.data;
      })
      .catch(error => {
        console.log(error);
      });
  }
};
</script>

jQuery中select标签绑定的onchange事件获取选中值

标签: select标签, vue异步传值

上面是“vue如何实现select下拉框异步传值”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

当前网址:https://m.ipkd.cn/webs_4514.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

帝国cms技巧之模板使用php5.3.*版本无法连接到My
js如何将数字转换为小数格式字符串
Vue项目中如何实现图片懒加载(附完整代码)
vuejs导入excel表格解析成JSON数据(日期变成数字)解决方法
vue项目开发引入百度echarts报"export 'default' (imported as 'echarts') was not found in 'echarts'错误解决方法