使用vue,axios和laravel时是否存在重现json数据的问题?

时间:2017-07-25 12:46:52

标签: laravel vue.js axios

我正在尝试复制关于vuecasts的教程(https://laracasts.com/series/learn-vue-2-step-by-step/episodes/18)。

一切看起来都很好,除了警告我没有任何错误:

  

资源被解释为文档但以MIME类型传输   application / json:“http://vueme.app:8000/skills

我已尝试将内容类型更改为text / html,如下所示: Resource interpreted as Document but transferred with MIME type application/json warning in Chrome Developer Tools

web.php:

Route::get('/', function () {
    return view('welcome');
});


Route::get('skills', function(){
return ['javascript', 'php', 'python'];
});

welcome.blade.php:

<!doctype html>
<html lang="{{ app()->getLocale() }}">
    <head>
        <meta charset="utf-8">
        <title>Laravel</title>
    </head>
    <body>

        <div id="root">
            <ul>
                <li v-for="skill in skills" v-text="skill"></li>
            </ul>
        </div>
        <script scr="https://unpkg.com/axios/dist/axios.min.js"></script>
        <script scr="https://unpkg.com/vue"></script>
        <script scr="/js/app.js"></script>
    </body>
</html>

app.js:

new Vue({
    el: '#root',
    data:{
        skills:[]
    },
    mounted(){
        axios.get('/skills').then(response => this.skills = response.data);
    }
});

什么不起作用?

0 个答案:

没有答案