在我的 Vaadin 12 项目中:
import com.vaadin.flow.component.dependency.HtmlImport
import com.vaadin.flow.component.dependency.JavaScript
import com.vaadin.flow.component.dependency.StyleSheet
import com.vaadin.flow.component.html.Div
import com.vaadin.flow.component.page.BodySize
import com.vaadin.flow.component.page.Page
import com.vaadin.flow.router.Route
import com.vaadin.flow.server.VaadinRequest
import org.slf4j.LoggerFactory
@Route(value = "myform")
@JavaScript("https://somejavascript.js")
class MyForm : Div() {
private val logger = LoggerFactory.getLogger(this::class.java)
init {
val request = VaadinRequest.getCurrent()
val myparam= request.getParameter("myparam")
logger.info("myparam = $myparam")
}
}
如您所见,我导入脚本:somejavascript.js
通过注释。好的。这个脚本有方法:myJavaScriptMethod
我如何在我的 Vaadin 类中调用这个方法MyForm
?