Laravel/Vue.js问题

Laravel/Vue.js问题,laravel,vue.js,Laravel,Vue.js,我的代码需要帮助。我想不出来。我得到一个“TypeError:this.$http未定义”,这让我发疯。我跟踪到$http,但不知道如何修复它。我刚刚完成了我的Laravel课程,但是Vue.js对我来说是新的。这是我的代码: <template> <div class="container"> <div class="row"> <div class="col-md-8 col-md-offset-2"&

我的代码需要帮助。我想不出来。我得到一个“TypeError:this.$http未定义”,这让我发疯。我跟踪到$http,但不知道如何修复它。我刚刚完成了我的Laravel课程,但是Vue.js对我来说是新的。这是我的代码:

<template>
  <div class="container">
        <div class="row">
              <div class="col-md-8 col-md-offset-2">
                    <div class="panel panel-default">
                    <div class="panel-body">
                          <textarea rows="3" class="form-control" v-model="content"></textarea>
                          <br>
                          <button class="btn btn-success pull-right" :disabled="not_working" @click="create_post()">
                                Create a post
                          </button>
                    </div>
                    </div>
              </div>
        </div>
  </div>
</template>

<script>
  export default {
        mounted() {

        },
        data() {
              return {
                    content: '',
                    not_working: true
              }
        },
        methods: {
              create_post() {
                    this.$http.post('/create/post', { content:          this.content })
                        .then((resp) => {
                              this.content = ''
                              noty({
                                      type: 'success',
                                      layout: 'bottomLeft',
                                      text: 'Your post has been   published !'
                              })
                              console.log(resp)
                        })
              }
        },
        watch: {
              content() {
                    if(this.content.length > 0)
                          this.not_working = false
                    else
                          this.not_working = true
              }
        }

  }
</script>


创建帖子 导出默认值{ 安装的(){ }, 数据(){ 返回{ 内容:“”, 不起作用:是的 } }, 方法:{ 创建_post(){ this.$http.post('/create/post',{content:this.content}) 。然后((resp)=>{ this.content=“” 诺蒂({ 键入:“成功”, 布局:“左下角”, 文字:“您的帖子已发布!” }) 控制台日志(resp) }) } }, 观察:{ 内容(){ 如果(this.content.length>0) 此值为0.not_working=false 其他的 此参数不工作=真 } } }
我认为您在提交post请求时出错。 您需要了解axios。 试试这个例子

axios.post('/create/post', this.content).then((response) => {
            // do something
        })

您是否通过npm安装vue资源来安装vue资源?有关@Ankittatel所说内容的更多详细信息,请参见本页..+1。观看这段关于laravel资产的laracast视频,然后看一看,不,我没有安装那个软件包。我使用的是PHPStorm,它通常会在需要时提示我安装一个软件包,我猜其中一个一定是滑倒了