vue.js - 如何将`item-text`与vue渲染功能绑定
问题描述
我正在尝试使用ONLYrender
函数呈现 Vue 模板。
在这种情况下,我试图绑定item-text
属性对象......但我的尝试失败了。
new Vue({
el: "#app",
data: () => ({
items: [
{ color: "blue", hash: "#42A5F5" },
{ color: "green", hash: "#FF4081" },
{ color: "red", hash: "#FF5252" },
{ color: "yellow", hash: "#5E35B1" }
]
}),
render: function(h) {
return h("v-app", { attrs: { dark: "dark" } }, [
h("v-container", [
h("v-select", { attrs: {
'items': this.items
'item-text' : color // doesn't work color is undefined
}
})
])
])
}
})
那么,有没有办法只使用该功能来做到这一点render
?
解决方案
使用函数将项目对象映射到颜色字符串。
h('v-select',{attrs : {'items' : this.items, 'item-text': it=>it.color }}),
推荐阅读
- spring-security - 在创建请求期间使用资源属性中的当前授权用户
- javascript - 变量名附加到 json 而不是变量值
- pyspark - 实例化“org.apache.spark.sql.hive.HiveExternalCatalog”时出错
- c# - Word inerop c#:在word文件中查找和替换星号
- laravel - ngenius-payment 无法集成,我跟着 DOCS,但给了我错误。它应该转到付款页面
- c# - 使用 modbus rtu 并在 c# 中读取保存值
- oracle - oracle forms 12. 如何显示十进制数的前导零
- ionic-framework - 如何从代码中关闭 Ionic 5 应用程序?
- pandas - pandas grouby 根据多个条件对日期时间列进行计数
- javascript - 自动完成中的 React Material UI 打开模式失去焦点