我正在使用 vue-chartjs 在网络应用程序上渲染图表。我知道如果您使用原始库,您可以打印图表。但是我不知道如何使用 vue 版本的库来做到这一点。
我的图表变量位于外部charts.js 文件中
import {Bar, mixins } from 'vue-chartjs'
Chart.defaults.global
let chartOptions = Chart.defaults.global;
const { reactiveProp } = mixins
export default {
extends: Bar,
mixins: [reactiveProp],
props: ['options'],
mounted () {
let that = this;
that.chartOptions = {
scales: {
yAxes: [{
ticks: {
suggestedMin: 0,
fontFamily: "'Overpass_Mono', 'Monaco', monospace",
fontColor: "rgba(254, 255, 248, 0.5)"
},
gridLines: {
color: 'rgba(255, 80, 248, 0.08)',
zeroLineColor: 'rgb(168, 119, 181)',
zeroLineWidth: 2
},
}],
xAxes: [{ …Run Code Online (Sandbox Code Playgroud) 在创建新节点时,我想创建相同的数据并将其推送到不同的节点.
"ins"节点是我将新数据推送到的节点:
root: {
doors: {
111111111111: {
MACaddress: "111111111111",
inRoom: "-LBMH_8KHf_N9CvLqhzU",
ins: {
// I am creating several "key: pair"s here, something like:
1525104151100: true,
1525104151183: true,
}
}
},
rooms: {
-LBMH_8KHf_N9CvLqhzU: {
ins: {
// I want it to clone the same data here:
1525104151100: true,
1525104151183: true,
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的功能代码如下,但它根本不起作用.当我使用onCreate触发器时,我甚至无法启动该功能(这是我所需要的).关于如何使这项工作的任何想法?
exports.updateRoom = functions.database.ref('doors/{MACaddress}/ins')
.onCreate((snapshot, context) => {
const timestamp = snapshot.val();
const roomPushKey = functions.database.ref('doors/{MACaddress}/inRoom');
console.log(roomPushKey);
return snapshot.ref.parent.parent.child('rooms').child(roomPushKey).child('ins').set(timestamp);
});
Run Code Online (Sandbox Code Playgroud)
注意:我已经摆弄了代码,我通过将触发器更改为onWrite来运行它,但是像这样我收到一条错误消息: "snapshot.val"不是函数 …
javascript database firebase firebase-realtime-database google-cloud-functions
如何将此 paypal curl 命令转换为 Axios?
\n\ncurl -v https://api.sandbox.paypal.com/v1/oauth2/token \\\n-H "Accept: application/json" \\\n-H "Accept-Language: en_US" \\\n-u "client_id:secret" \\\n-d "grant_type=client_credentials"\nRun Code Online (Sandbox Code Playgroud)\n\n我在 vue 中使用 vueAxios,因此是“ this. ”。
\n\nthis.axios.post(\'https://api.sandbox.paypal.com/v1/oauth2/token\',\n {\'Accept\': "application/json", \'Accept-Language\': "en_US", \n \'XXXXXX\': \'XXXXX\', // my paypal client ID and client secret \n \'grant_type\':\'client_credentials\'}\n )\n .then( response => {\n console.log("Response is: ", response);\n })\n .catch( error => {\n console.log("Error is :", error);\n});\nRun Code Online (Sandbox Code Playgroud)\n\n我收到此错误:
\n\n Error is : Error: Request failed with status code 401\n at createError (createError.js?16d0:16)\n at …Run Code Online (Sandbox Code Playgroud) 想象一下一个Vue.js应用程序,其中firebase中的数据结构将发展成如下所示:
item: {
name: itemName,
childOne: {
subChildA: true,
subChildB: true
},
childTwo: {
subChildA: true,
subChildB: true
}
}
Run Code Online (Sandbox Code Playgroud)
现在我有一个组件,我需要列出子节点的长度(这些子节点将只在以后添加).我的第一个想法是简单地这样做,但这个策略不起作用:
<tbody>
<tr v-for="item in items" >
<td>
{{item.childOne.length - item.childTwo.length}}
</td>
</tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)
所以我也得到了这样的长度:
<tbody>
<tr v-for="item in items" >
<td>
{{Object.keys(item.childOne).length - Object.keys(item.childTwo).length}}
</td>
</tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)
正如我所说,我需要在创建项目的子项之前呈现该组件...这些子节点稍后通过Google Cloud Function有条件地创建,因此我不可避免地从这个简单的结构开始:
item: {
name: itemName,
}
Run Code Online (Sandbox Code Playgroud)
...但在此阶段我收到一条错误消息:
TypeError:无法在Function.keys()中将undefined或null转换为对象
我在想如果我使用第一个策略,vue.js足够智能,可以避免这个错误渲染组件,如果没有子节点则不显示任何内容,但它无法获得长度.
当我添加子项时,第二种策略可以正常工作,但它无法处理数据的初始缺失,甚至无法呈现视图.
当子节点还没有时,是否有使用第二种策略来防止此错误?
vue.js ×3
firebase ×2
javascript ×2
axios ×1
chart.js ×1
curl ×1
database ×1
httprequest ×1
paypal ×1
printing ×1
vue-chartjs ×1