【发布时间】:2017-01-25 02:12:42
【问题描述】:
所以我有一个模板 .vue 文件:
<template>
<div id="app">
<textarea v-model="input" :value="input" @input="update"></textarea>
<div v-html="compiledMarkdown"></div>
</div>
</template>
<script>
var markdown = require('markdown').markdown;
export default {
name: 'app',
data() {
return {
input: '# Some default data'
}
},
mounted: function () {
this.$nextTick(function () {
this.$http.get(window.location.pathname + '/data').then((response) => {
this.input = response.body.markdown;
}) })
},
computed: {
compiledMarkdown: function() {
this.$http.post(window.location.pathname, {
"html": markdown.toHTML(this.input)}).then(function() {
},function() {
});
return markdown.toHTML(this.input);
}
},
methods: {
update: function(e) {
this.input = e.target.value
}
}
}
</script>
在挂载的函数中,我试图将输入设置为等于 HTTP 请求的响应,但是当您查看此文件时,this.input 仍然与最初声明的相同。如何将已编译的Markdown 函数中的this.input 更改为已安装函数中的this.input。我还可以采取哪些其他方法?
【问题讨论】: