我对 vue.js 很陌生,我正在尝试构建一个基本应用程序来显示从 API 获取的数据。
我不明白为什么我不能在脚本中使用 console.log :
<script>
import Header from './components/layout/Header.vue'
import Todos from './components/Todo.vue'
export default {
name: 'app',
components: {
Todos,
Header,
},
data () {
return {
todos : []
}
},
methods : {
created () {
fetch('https://jsonplaceholder.typicode.com/todos')
.then( resp => resp.json())
.then( data => {
console.log(data);
})
.catch(err => err)
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
我总是收到“意外的控制台声明”
有谁知道我如何在 vue 脚本中控制台日志内容?我错过了什么吗?
多谢 !!
我已经在 Laravel 项目上实现了缓存标签,并且我的控制器中有类似的内容:
if (Cache::tags(['api'])->has('someKey')) {
return new JsonResponse(Cache::tags(['api'])->get('someKey'));
}
Run Code Online (Sandbox Code Playgroud)
我想编写一个 phpunit 测试来测试这段代码:我模拟了 Laravel 文档中的缓存,但我还没有找到任何关于如何tags在模拟缓存上使用的内容
我试过 :
Cache::tags(['api'])->shouldReceive('has')->with('someKey')->andReturn(true)->once();
Run Code Online (Sandbox Code Playgroud)
或者
Cache::shouldReceive('has')->tags(['api'])->with('someKey')->andReturn(true)->once();
Run Code Online (Sandbox Code Playgroud)
但这都不起作用,我得到了Call to undefined method Illuminate\Cache\ArrayStore::shouldReceive()或
call_user_func_array() expects parameter 1 to be a valid callback, class 'Mockery\Expectation' does not have a method 'tags'
有人知道吗?多谢 :)