Javascript 如何在QML中使用document.cookie设置cookie?
我有以下qml代码Javascript 如何在QML中使用document.cookie设置cookie?,javascript,qt,cookies,qml,Javascript,Qt,Cookies,Qml,我有以下qml代码 WebEngineView { id: _webView height: parent.height - 20 width: parent.width - 20 x: 10 y: 10 backgroundColor: "#e3e3e6" userScripts: WebEngineScript { injectionPoint: WebEngineScript.DocumentCr
WebEngineView {
id: _webView
height: parent.height - 20
width: parent.width - 20
x: 10
y: 10
backgroundColor: "#e3e3e6"
userScripts: WebEngineScript {
injectionPoint: WebEngineScript.DocumentCreation
sourceCode: "document.cookie = " + readyCookie
}
url: "http://example.com"
}
我在readyCookie
变量中有一个cookie。例如:
JSESSIONID=DUo6nBoJgAJAsimljT5PdfGc5hs97kSbb1LqMjgL.dfvdf-dfv-fdf; domain=something.ru; path=/
我正在尝试在url:http://example.com“
字符串,使用
userScripts: WebEngineScript {
injectionPoint: WebEngineScript.DocumentCreation
sourceCode: "document.cookie = " + readyCookie
}
但这不起作用。饼干是对的
有什么想法吗?问题解决了:
userScripts: WebEngineScript {
injectionPoint: WebEngineScript.DocumentCreation
sourceCode: "document.cookie = \"" + readyCookie + "\""
}