Tag: JavaScript

KotlinJS中的Kootlin失败的世界没有定义

我有一个名为Main.kt的Kotlin文件 package com.ahp.mui fun main(args: Array) { println(“…”) println(“Hello World”) } 项目设置为KotlinJS项目。 一旦我编译,我看到下面的文件正在生成: target/production/ahp-mui/ahp-mui.js target/production/ahp-mui/ahp-mui.js.map target/production/ahp-mui/ahp-mui.meta.js 主生成的文件包含: (function (Kotlin) { ‘use strict’; var _ = Kotlin.defineRootPackage(null, /** @lends _ */ { com: Kotlin.definePackage(null, /** @lends _.com */ { ahp: Kotlin.definePackage(null, /** @lends _.com.ahp */ { mui: Kotlin.definePackage(null, /** @lends _.com.ahp.mui */ { main_kand9s$: function (args) […]

ReferenceError:ok没有在Kotlin Javascript的QUnitAsserter.assertTrue中定义

Kotlin版本1.0.x-1.1.0支持使用QUnit的unit testing,但是当我加载测试时,会抛出这个exception: ReferenceError: ok is not defined at QUnitAsserter.assertTrue_4mavae$ (file:///D:/neoranga/Mis%20documentos/GitHub/FibonacciCounter/app/build/classes/test/lib/kotlin-test-js.js:50:5) at assertTrue (file:///D:/neoranga/Mis%20documentos/GitHub/FibonacciCounter/app/build/classes/test/lib/kotlin-test-js.js:93:27) at QUnitAsserter.assertTrue_o10pc4$ (file:///D:/neoranga/Mis%20documentos/GitHub/FibonacciCounter/app/build/classes/test/lib/kotlin-test-js.js:47:5) at QUnitAsserter.Asserter.assertEquals_lzc6tz$ (file:///D:/neoranga/Mis%20documentos/GitHub/FibonacciCounter/app/build/classes/test/lib/kotlin-test-js.js:182:10) at assertEquals (file:///D:/neoranga/Mis%20documentos/GitHub/FibonacciCounter/app/build/classes/test/lib/kotlin-test-js.js:108:20) at AppTest.myFirstTest (file:///D:/neoranga/Mis%20documentos/GitHub/FibonacciCounter/app/build/classes/test/app_test.js:17:5) at Object. (file:///D:/neoranga/Mis%20documentos/GitHub/FibonacciCounter/app/build/classes/test/app_test.js:29:21) 这是我的测试课: import org.junit.Test import kotlin.test.assertEquals class AppTest { @Test fun myFirstTest() { assertEquals(1, 1, “Test in test folder works”) } } 这是加载测试的html代码: Fibonacci Counter Placeholder

在Kotlin中有属性的函数types

我可以在TypeScript中指定这个(因此可以在JavaScript中完成): interface Foo { (arg: any): void foo: string } Kotlin能达到同样的效果吗?

在Eclipse Maven项目中使用Kotlin Javascript进行DOM操作

在Eclipse中,我有一个Kotlin Javascript Maven项目,其中包含以下pom.xml文件: … org.jetbrains.kotlin kotlin-stdlib 1.1.51 org.jetbrains.kotlin kotlin-stdlib-js 1.1.51 src/main/kotlin org.jetbrains.kotlin kotlin-maven-plugin … org.apache.maven.plugins maven-dependency-plugin unpack compile unpack … 如果我做一个正常的println(“Hello World!”)消息,它会起作用。 但是我不能运行下面的代码: 我做错了什么?

Kotlin和Firebase云function的update()方法

我正在使用Kotlin为Firebase云端function生成Javascript代码。 我想调用update方法,传递一些值作为参数。 在Kotlin中,我必须传递一个Map作为update()的参数: val map = mutableMapOf() //also tried with a Hashmap: same result //generate some values for(i in 0 until 3){ map.put(“key$i”, i) } console.log(map.keys.toList().toString()) //log map keys console.log(map.values.toList().toString()) //log map values ref.child(“values”).update(map) Kotlin生成的JavaScript代码: var LinkedHashMap_init = Kotlin.kotlin.collections.LinkedHashMap_init_q3lmfv$; function main$lambda(event){ var map = LinkedHashMap_init(); for (var i = 0; i < 3; i++) { […]

Kotlin JavaScript Date.now()返回types

我想知道为什么Kotlin JavaScript Date类为getTime函数返回Double。 根据文档 , getTime函数应该返回自1970年1月1日00:00:00 UTC以来的毫秒数。 我知道JS没有64位的数字表示,但是由于Kotlin 模拟了Longs,我觉得Date.now()和Date().getTime()应该是一个Long返回的值。 至少返回一个Int更合理。 是否有任何理由返回Double而不是整数?

在Kotlin中包含Javascript文件(不是模块)

我有两个JavaScript文件。 我有一些生成Javascript文件的Kotlin代码。 我也有一个文件(称为file.js),这取决于从Kotlin生成的JavaScript文件。 有没有办法让我使用Gradle在Kotlin生成的JavaScript文件中包含file.js? 有没有可以将资源Javascript文件附加到生成的输出的设置? 我的动机是慢慢地将我的JavaScript项目转换成Kotlin,并且由于项目的结构,我无法创建一个模块。 只是想知道是否有可能做到这一点,如何做到这一点。

Android WebView跳转到每个页面上的更新(?)

我正在执行标准的Web视图活动与enabled JavaScript,我遇到了一些不必要的行为,使不可能与(一,现在)的网页进行交互。 class WebViewActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_fullscreen) supportActionBar?.setDisplayHomeAsUpEnabled(true) web_view.webChromeClient = WebChromeClient() web_view.webViewClient = WebViewClient() } override fun onPostCreate(savedInstanceState: Bundle?) { super.onPostCreate(savedInstanceState) web_view.settings.javaScriptEnabled = true web_view.loadUrl("https://www.google.com") } } 标准的东西,但是当我从www.google.com导航到m.9gag.com ,webview没有正确处理这个请求 – 每次我滚动或点击一些引用,它跳转到顶部,页面变得没有反应。 我查看了桌面浏览器中的日志,似乎与该网页中的广告更新有关。 但我可能是错的。 这种行为在我安装在测试设备上的任何移动浏览器中都不存在,所以我想也许可以通过更改webview的一些设置来防止这种行为。 更新 我通过启用WebView.setWebContentsDebuggingEnabled(true)将Chrome调试器附加到设备上 事实证明,网站只是refreshes自己在无尽的循环,即使切换到另一个应用程序,webview仍然不断刷新。 您可以在红线上方看到整个网络请求历史记录

如何在WebView Android中获取OnScroll位置

我尝试使用此代码在webview中获取当前位置 class ObservableWebView : WebView { private val TAG: String = ObservableWebView::class.java.simpleName constructor(context: Context?) : super(context) constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) { super.onScrollChanged(l, t, oldl, oldt) Log.d(TAG, "scroll1 " + l + " […]

如何将Android的对象数组传递给React Native?

我试图从原生Android传递数据到React Native。 数据是由应该调度的动作组成的对象数组。 例 { "actions: [ { "authenticationType: "strong", "type: "AUTHENTICATION_URL", "url: "https://foo.bar/", }, ], } 我试图使用com.facebook.react.bridge.Arguments类来做类似的事情 val arguments = Arguments.createMap().apply { putString("path", "general/authentication") putArray("actions", Arguments.fromList(listOf( mapOf("authenticationType" to "strong", "type" to "AUTHENTICATION_URL", "url" to url )))) } 但只会导致 09-14 20:08:53.996 10437 10437 I zygote : Thread[1,tid=10437,Native,Thread*=0xb18da000,peer=0x73d2f568,"main"] recursive attempt to load library "/data/app/com.getdreams-MO6VYrPeHVgAkBP2ori8SA==/lib/x86/libfb.so" 不确定如何创建javascript对象的数组。 有没有人有任何建议如何可能更好地使用com.facebook.react.bridge.Arguments […]