Vuetify v-select 项目不改变价值
Vuetify v-select item doesn't change value
编辑 我正在使用 Vuetify's v-select not vue-select component。
当我创建 selection 时,什么也没有发生。设置初始值有效。
模板:
<v-select
:items="accountTypes"
v-model="formData.AccountName">
</v-select>
脚本数据:
accountTypes: [
{value: 1, text: "student"},
{value: 2, text: "company"}
],
formData: {
FirstName: '',
LastName: '',
Email: '',
AccountTypeId: 1,
AccountName: 1,
UserName: '',
Password: ''
},
我查看了源代码,发现 selectItem 不会在 v-select 的生成器第 128 行(版本 0.14.8,参见代码下)
const data = {
on: { click: e => this.selectItem(item) },
props: {
avatar: item === Object(item) && 'avatar' in item,
ripple: true,
value: active
}
}
我试过升级和降级模块,但我认为某处存在某种 "stupid" 错误。感谢您的任何输入:)
我在 package.json 中的依赖项:
"dependencies": {
"axios": "^0.16.2",
"express": "^4.15.4",
"js-cookie": "^2.1.4",
"nuxt": "^0.10.7",
"vue": "^2.4.2",
"vue-server-renderer": "^2.4.2",
"vue-template-compiler": "^2.4.2",
"vuetify": "^0.14.8"
},
"devDependencies": {
"cross-env": "^5.0.5",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1"
}
}
已更新
问题可能是您没有最新版本的 Vue(最新的 Vuetify 需要 2.4.1)。这就是我 运行 将这段代码放在一起的原因。这按预期工作。
new Vue({
el: '#app',
data: {
accountTypes: [{
value: 1,
text: "student"
}, {
value: 2,
text: "company"
}],
formData: {
FirstName: '',
LastName: '',
Email: '',
AccountTypeId: 1,
AccountName: 1,
UserName: '',
Password: ''
}
},
})
form {
width: 50%;
}
<link href="https://unpkg.com/vuetify/dist/vuetify.min.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.min.js"></script>
<script src="https://unpkg.com/vuetify/dist/vuetify.js"></script>
<v-app id="app">
<form>
<v-select :items="accountTypes" v-model="formData.AccountName" label="Select" single-line bottom>
</v-select>
{{formData.AccountName}}
</form>
</v-app>
编辑 我正在使用 Vuetify's v-select not vue-select component。
当我创建 selection 时,什么也没有发生。设置初始值有效。
模板:
<v-select
:items="accountTypes"
v-model="formData.AccountName">
</v-select>
脚本数据:
accountTypes: [
{value: 1, text: "student"},
{value: 2, text: "company"}
],
formData: {
FirstName: '',
LastName: '',
Email: '',
AccountTypeId: 1,
AccountName: 1,
UserName: '',
Password: ''
},
我查看了源代码,发现 selectItem 不会在 v-select 的生成器第 128 行(版本 0.14.8,参见代码下)
const data = {
on: { click: e => this.selectItem(item) },
props: {
avatar: item === Object(item) && 'avatar' in item,
ripple: true,
value: active
}
}
我试过升级和降级模块,但我认为某处存在某种 "stupid" 错误。感谢您的任何输入:)
我在 package.json 中的依赖项:
"dependencies": {
"axios": "^0.16.2",
"express": "^4.15.4",
"js-cookie": "^2.1.4",
"nuxt": "^0.10.7",
"vue": "^2.4.2",
"vue-server-renderer": "^2.4.2",
"vue-template-compiler": "^2.4.2",
"vuetify": "^0.14.8"
},
"devDependencies": {
"cross-env": "^5.0.5",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.1"
}
}
已更新
问题可能是您没有最新版本的 Vue(最新的 Vuetify 需要 2.4.1)。这就是我 运行 将这段代码放在一起的原因。这按预期工作。
new Vue({
el: '#app',
data: {
accountTypes: [{
value: 1,
text: "student"
}, {
value: 2,
text: "company"
}],
formData: {
FirstName: '',
LastName: '',
Email: '',
AccountTypeId: 1,
AccountName: 1,
UserName: '',
Password: ''
}
},
})
form {
width: 50%;
}
<link href="https://unpkg.com/vuetify/dist/vuetify.min.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.min.js"></script>
<script src="https://unpkg.com/vuetify/dist/vuetify.js"></script>
<v-app id="app">
<form>
<v-select :items="accountTypes" v-model="formData.AccountName" label="Select" single-line bottom>
</v-select>
{{formData.AccountName}}
</form>
</v-app>