javascript - 如何在Vue中为父组件的数据设置新值
问题描述
<template>
<div>
<input @keypress.enter="setLocation" class="search" type="text" placeholder="find a city" v-model="newCity">
</div>
<script>
export default {
props:['city'],
data(){
return{
newCity:""
}
},
methods:{
setLocation(event){
this.city = newCity
this.$emit('newLocation', this.city)
}
}
}
当我试图提交它时,它说 newCity 没有定义。他们是否在 Vue.js 更新中更改了 v-model 属性?
解决方案
推荐阅读
- python - 使用 seaborn 可视化缺失数据的出现频率
- jquery - Jquery .attr() 在 onclick 事件期间未读取我的“数据链接”html 值
- r - R - 引用矩阵中的值
- python - 使用部分原始文件名动态命名导入 Python 的 DataFrame
- java - 如何解决:javax.xml.transform.sax.SAXSource 无法转换为 java.io.Serializable [BonitaSoft]
- angular - 窗口打开功能有效但立即关闭新打开的窗口
- jquery - jQuery 在 ASP.NET Core 2.2 Razor 视图中不可用
- javascript - Codility CyclicRotation Javascript 解决方案:空数组返回错误
- c - C中的整数和浮点除法
- django-rest-framework - 如何将 POST 数据与 Django REST Framework 中的现有实例数据合并?