在body从Authorize.net的沙盒API的响应是:
{
"messages": {
"resultCode": "Error",
"message": [
{
"code": "E00012",
"text": "You have submitted a duplicate of Subscription 5777085. A duplicate subscription will not be created."
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我去解析它时:
try {
bodyObj = JSON.parse(body);
} catch (ex) {
console.error(ex);
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
语法错误:JSON 中位置 0 的意外标记
和这个: console.log(response.headers['content-type']);
返回这个: application/json; charset=utf-8
我究竟做错了什么?我想将 JSON 解析为 JS 对象。
我有一个服务器端渲染production模式 Vite 应用程序。我的问题是:网页通常会重新加载并且控制台将显示[vite] connecting.... 我将此追溯到 vite 代码库的热模块重新加载部分。但是,我不想hmr打开 for production,但无论我将以下两个设置设置为 ,它似乎仍然打开false:
在我的vite.config.js文件中我有:
...
export default defineConfig({
server: {
hmr: false,
},
Run Code Online (Sandbox Code Playgroud)
另外,在我的 NodeJSserver.js文件中,我有:
const vite = await createViteServer({
server: { middlewareMode: 'ssr', hmr: false },
})
Run Code Online (Sandbox Code Playgroud)
如何关闭 Vite 的功能hmr?
我有一个phonegap/cordova应用程序,我想用Precise Biometric的智能卡Tactivo阅读器保护.我是智能卡集成的新手,而精确生物识别技术似乎没有非常丰富的文档.但是我发现我需要为phonegap创建自己的插件才能使用读卡器.
我的问题是:是否已经为此创建了一个插件,或者有人发布了我需要的插件代码示例?
到目前为止,我在plugin.xml文件中有这个代码:
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:rim="http://www.blackberry.com/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-device"
version="1.0.0-dev">
<name>smartCard</name>
<description>Cordova smartCard Plugin</description>
<license>Apache 2.0</license>
<keywords>cordova,smartCard</keywords>
<repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git</repo>
<issue>https://issues.apache.org/jira/browse/CB/component/12320648</issue>
<js-module src="www/smartCard.js" name="smartCard">
<clobbers target="smartCard" />
</js-module>
...
<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="smartCard" >
<param name="android-package" value="org.apache.cordova.smartCard.SMARDCARD"/>
</feature>
</config-file>
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="com.precisebiometrics.android.mtk.manager.permission.BIOMETRIC_DATA" />
</config-file>
<source-file src="src/android/smartCard.java" target-dir="src/org/apache/cordova/smartCard" />
<js-module src="www/smartCardHandle.js" name="smartCardHandle">
<clobbers target="smartCardrHandle" />
</js-module>
</platform>
Run Code Online (Sandbox Code Playgroud)
www/*.js文件中没有代码
我只想指出正确的方向.谢谢.
我正在尝试从我自己的域发送电子邮件,而不使用外部SMTP服务器.我正在使用NodeMailer的SMTP连接:
let options = {
secure: true,
port: consts.portOut,//465
host: consts.host, //mydomain.com
transactionLog: true,
debug: true,
requireTLS: true,
authMethod: 'PLAIN',
};
let connection = new SMTPConnection(options);
connection.connect(function() {
let auth = {
user: 'abc',
pass: 'def'
};
connection.login(auth, function(err) {
if (err) {
console.log("Authentication failed!", err);
}
console.log("Authentication to SMTP server successful.");
let envelope = {
from: 'fee@mydomain.com',
to: 'myemail@gmail.com'
};
let message = 'message hello world';
connection.send(envelope, message, function(err, info) {
if (err) {
console.log("err:::", err);
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试从流中加载视频。即使整个视频尚未“下载”,我也希望能够“播放”视频。base64 数据以缓冲区块流的形式传入。
const videoTag = document.getElementById('videoTag');
const mimeCodec = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"';
const mediaSource = new MediaSource();
videoTag.src = URL.createObjectURL(mediaSource);
await new Promise((resolve, reject) => {
mediaSource.addEventListener('sourceopen', function (_) {
resolve();
});
});
const sourceBuffer = mediaSource.addSourceBuffer(mimeCodec);
for await (const chunk of ipfsNode.cat(CID)) {//Chunk is coming in as an array buffer
sourceBuffer.appendBuffer(chunk);
}
sourceBuffer.addEventListener('updateend', async function (_) {
mediaSource.endOfStream();
$('#videoTag')[0].load();
});
Run Code Online (Sandbox Code Playgroud)
我已经尝试使用new MediaSource()和sourceBuffer.appendBuffer(chunk);推新下载的数据块的视频,但不仅在视频没有播放过,我现在用的方法要求之前,整个视频下载可以玩。
如何将我chunk的 base64 数据放入视频中?
编辑(回应评论):无论我是使用字符串还是二进制流,我都对如何将流导入视频感到有些困惑。
我正在尝试使用window.crypto以下方法加密一些文本:
await crypto.subtle.encrypt(algorithm, key, dataArrayBuffer).catch(error => console.error(error));
Run Code Online (Sandbox Code Playgroud)
但是我收到这个错误AES key data must be 128 or 256 bits。我正在使用 PBKDF2 从密码创建 256 位密钥,并指定密钥长度为256:
window.crypto.subtle.deriveKey(
{
"name": "PBKDF2",
"salt": salt,
"iterations": iterations,
"hash": hash
},
baseKey,
{"name": "AES-GCM", "length": 256}, //<------------
true,
["encrypt", "decrypt"]
);
Run Code Online (Sandbox Code Playgroud)
但我最终得到这个键edi5Fou4yCdSdx3DX3Org+L2XFAsVdomVgpVqUGjJ1g=后,我exportKey就和它转换来自ArrayBuffer于一个string与长度44字节,352位...
这可以解释错误,但是如何256从window.crypto's创建一个实际的位键PBKDF2?
JSFiddle:https ://jsfiddle.net/6Lyaoudc/1/
我正在创建一个在线文本编辑器。我需要能够从 textarea 的标记中获取用户文本,操作此文本并将其绑定回 textarea,但其中包含 HTML。
例子:
<textarea v-model="someText"></textarea>
Run Code Online (Sandbox Code Playgroud)
哪里someText设置为:
someText: '<b>bold</b>.. not bold'
Run Code Online (Sandbox Code Playgroud)
并应显示为: 粗体.. 不粗体
代替: <b>bold</b>.. not bold
我有一种感觉,这是不可能的textarea标签,但有什么方法可以做到这一点?
当我尝试更新自定义文本区域组件的模型数据时this.message='<span id="foo">bar</span>,文本和html不会像hjecttextarea标签那样显示,但我可以在Vue开发工具的控制台中看到更新.我也试过切换到一个对象而不是字符串并使用Vue.set,但这也不起作用.
对于如何解决这个问题,有任何的建议吗?
该htmlTextArea组件的目标是从htmlTextArea标签获取用户文本(这可行),操作此文本并将其绑定回textarea,但其中包含HTML.
自定义文本区域组件:
<template>
<div contenteditable="true" @input="updateHTML" class="textareaRoot"></div>
</template>
<script>
export default {
// Custom textarea
name: 'htmlTextArea',
props:['value'],
mounted: function () {
this.$el.innerHTML = this.value;
},
methods: {
updateHTML: function(e) {
this.$emit('input', e.target.innerHTML);
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
其他组件:
<template>
...
<htmlTextArea id="textarea" v-model="message"></htmlTextArea>
...
</template>
<script>
data: {
return {
message: 'something'//this works
}
}
...
methods: {
changeText() {
this.message='<span id="foo">bar</span>'//this does not
}
},
components: {
htmlTextArea
}
</script>
Run Code Online (Sandbox Code Playgroud) 我有两个Android应用程序,一个用Java编写,另一个用javascript编写,包含在phonegap应用程序中.我需要我的java应用程序来设置用户首选项(字符串)和js应用程序来获取此字符串.
在我的java应用程序中设置用户首选项后,我现在需要知道如何在我的js应用程序中检索它.怎么样?我试过两个phonegap插件,(https://github.com/macdonst/AppPreferences和https://github.com/apla/me.apla.cordova.app-preferences)
但是,它们似乎不是为了从其他应用程序获取用户首选项而构建的.
我还应该尝试什么?我应该坚持用户偏好吗?
谢谢,
javascript ×3
android ×2
cordova ×2
vue.js ×2
vuejs2 ×2
data-binding ×1
email ×1
encryption ×1
firebase ×1
html ×1
html5-video ×1
ipfs ×1
java ×1
json ×1
node.js ×1
nodemailer ×1
nuxt.js ×1
response ×1
sendmail ×1
smartcard ×1
smtp ×1
smtpclient ×1
video ×1
vite ×1