0

Stackoverflowers, I'm a newbie of vue.js, I try to implement a binding effect which can enable the changing of binding created by v-model. To put things clear, I give an example as following:

<codemirror ref="outputCm" v-model="output" :options="cmOutputOptions"></codemirror>

Here we have a codemirror element, it's content is binded with variable output, is it possible in some place after I changed output to some-variable, its content now is binded with some-variable? I tried to use assignment, it didn't work. And I tried my best to google, but I'm still disappointed. If anybody know how to give this a shot, I'm appreciated.

dulq
  • 245
  • 3
  • 11
  • 2
    What are you trying to accomplish by rebinding the model? It sounds like you've picked a solution without examining the real problem. – David Weldon Aug 27 '19 at 06:39
  • I just want to reuse this codemirror to hold json output or plain text (some logs), either has updates, the content of codemirror just sync with it. – dulq Aug 27 '19 at 06:46

1 Answers1

0

yes you could make it but from your data object

data: {
    output: (your logic here)? some-variable : 'some thing else'
}
Joseph
  • 5,644
  • 3
  • 18
  • 44
  • Hi, Joseph, I give your method a try, it didn't work as expected. In data object, I make output as `output: this.showLogs ? this.log : this.jsonOutput`, but nothing outputs – dulq Aug 27 '19 at 07:29