Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js Vue Multiselect:如何在第一次选择后自动填充其余输入字段?_Vue.js_Vue Multiselect - Fatal编程技术网

Vue.js Vue Multiselect:如何在第一次选择后自动填充其余输入字段?

Vue.js Vue Multiselect:如何在第一次选择后自动填充其余输入字段?,vue.js,vue-multiselect,Vue.js,Vue Multiselect,我正在使用插件,想知道当用户从初始下拉列表中选择项目时,如何自动填充其他输入字段customer_firstname和customer_email 场景:如果数据库/下拉列表中存在该名称,则用户可以选择该名称,Vue将自动填充从选项数组中获取的其余输入字段。否则,如果名称不存在,用户可以为每个附加输入字段(例如,customer_firstname、customer_email)标记/创建新值 这是我的代码,它可以正常工作,只需要帮助连接根据lastname下拉列表的初始选择自动填充其余输入字段

我正在使用插件,想知道当用户从初始下拉列表中选择项目时,如何自动填充其他输入字段customer_firstname和customer_email

场景:如果数据库/下拉列表中存在该名称,则用户可以选择该名称,Vue将自动填充从选项数组中获取的其余输入字段。否则,如果名称不存在,用户可以为每个附加输入字段(例如,customer_firstname、customer_email)标记/创建新值

这是我的代码,它可以正常工作,只需要帮助连接根据lastname下拉列表的初始选择自动填充其余输入字段的功能

Vue模板:

姓氏: {{props.option.lastname} {{props.option.lastname},{{props.option.firstname}}-{{props.option.email} 没有结果,布拉 数据:{{customer_last_name}} 名字: 电邮: Vue脚本:

新Vue{ 组成部分:{ Multiselect:window.VueMultiselect.default }, 数据:{ 客户姓氏:, 客户名称:, 客户电子邮件:, 选项:[{uid:1,名字:John,姓氏:Doe,电子邮件:johndoe@aol.com,电话:空,c_组织:ACME,c_标题:空},{uid:2,名字:Mary,姓氏:Smith,电子邮件:msmith@aol.com,电话:空,学校组织:NBA,学校名称:Miss},{uid:3,姓:Mike,姓:Verlander,电子邮件:asdafsdf@aol.com,电话:空,c_组织:MLB,c_职务:Mr}] }, 方法:{ addTag新标签{ 常数部分=新标记拆分','; 常量标记={ uid:this.options.length+1, 名字:parts.pop, 姓氏:parts.pop } this.options.pushtag this.customer\u last\u name=标签; }, customerSelectName选项{ 返回`${option.lastname},${option.firstname}` }, onSelect选项,uid{ console.logoption,uid } } }.$mount'app'
你几乎拥有了你所需要的一切。onSelect方法将附加到multiselect的select事件,因此您可以直接使用它

在onSelect方法中,添加以下行:

this.customer_first_name = option.firstname;
this.customer_email = option.email;
这将为变量指定在选择选项时获得的对象的属性