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
Javascript 检索v-for数组中textarea的值_Javascript_Vue.js_V For - Fatal编程技术网

Javascript 检索v-for数组中textarea的值

Javascript 检索v-for数组中textarea的值,javascript,vue.js,v-for,Javascript,Vue.js,V For,考虑到这种情况 At.vue模板 <div v-for="(tweet, index) in tweets"> <div class="each_tweet"> <textarea v-on:keyup="typing(index)" placeholder="What's happening now">{{ tweet.content }}</textarea> </div> </di

考虑到这种情况

At.vue
模板

<div v-for="(tweet, index) in tweets">
  <div class="each_tweet">
    <textarea v-on:keyup="typing(index)"
              placeholder="What's happening now">{{ tweet.content }}</textarea>
  </div>
</div>
我的问题是:

1) 有没有办法将textarea的值与每个tweet对象的内容同步?该值引用textarea的内部文本

2) 有没有办法在“键入”方法中获取textarea的值

您可以使用:

可以使用v-model指令在上创建双向数据绑定 表单输入和文本区域元素

例如:

<div v-for="(tweet, index) in tweets">
  <div class="each_tweet">
    <textarea v-on:keyup="typing(index)"
              v-model="tweet.content"
              placeholder="What's happening now"></textarea>
  </div>
</div>

谢谢!我不知道我可以这样使用v型车。我花了很多时间思考jquery或getelementbyid方法。
<div v-for="(tweet, index) in tweets">
  <div class="each_tweet">
    <textarea v-on:keyup="typing(index)"
              v-model="tweet.content"
              placeholder="What's happening now"></textarea>
  </div>
</div>