我有一段代码:
override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) {
try {
Log.d("DEBUG POST=====>", response.body()!!.string())
}catch(e:IOException) {
e.printStackTrace()
}
}
Run Code Online (Sandbox Code Playgroud)
当我使用时,response.body()!!.string()
我得到了正确的输出和JSON体.
当我使用:response.body().toString()
我得到okhttp3.ResponseBody$1@c626d25
任何人都可以告诉我这两种方法有什么区别.
我正在使用:以VueJs 2为起点的全局数据,因为我只想读 /写一个变量。
我在现有代码中添加了@click事件以修改变量,但出现“未捕获的ReferenceError:未定义$ myGlobalStuff”。
谁能看到我在做什么错:
HTML:
<div id="app2">
{{$myGlobalStuff.message}}
<my-fancy-component></my-fancy-component>
<button @click="updateGlobal">Update Global</button>
</div>
Run Code Online (Sandbox Code Playgroud)
VueJS:
var shared = {消息:“我的全局消息”}
shared.install = function(){
Object.defineProperty(Vue.prototype, '$myGlobalStuff', {
get () { return shared }
})
}
Vue.use(shared);
Vue.component("my-fancy-component",{
template: "<div>My Fancy Stuff: {{$myGlobalStuff.message}}</div>"
})
new Vue({
el: "#app2",
mounted(){
console.log(this.$store)
},
methods: {
updateGlobal: function() {
$myGlobalStuff.message = "Done it!"
return
}
}
})
Run Code Online (Sandbox Code Playgroud)
如您所见,我向现有代码添加的内容很少,而且效果很好。
Any help on what I am overlooking would be appreciated.
根据GitHub上的文档,我的build.gradle(app)是:
repositories {
jcenter()
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.dubsmash.volley:library:2.0.1'
compile 'ca.mimic:oauth2library:2.3.0'
compile 'com.github.kittinunf.fuel:fuel:<latest-version>' //for JVM
compile 'com.github.kittinunf.fuel:fuel-android:<latest-version>' //for Android
compile 'com.github.kittinunf.fuel:fuel-livedata:<latest-version>' //for LiveData support
compile 'com.github.kittinunf.fuel:fuel-rxjava:<latest-version>' //for RxJava support
compile 'com.github.kittinunf.fuel:fuel-gson:<latest-version>' //for Gson support
compile 'com.github.kittinunf.fuel:fuel-jackson:<latest-version>' //for Jackson support
}
Run Code Online (Sandbox Code Playgroud)
当我尝试构建Gradle时,会为所有燃料组件抛出以下错误:
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.github.kittinunf.fuel:fuel-livedata:<latest-version>.
Could not resolve com.github.kittinunf.fuel:fuel-livedata:<latest-version>.
Required by:
project :app …
Run Code Online (Sandbox Code Playgroud)