我最近Vue.js在 Twitter 上看到了 Evan You 的这个片段,我不明白initscript 标签中的属性是做什么的。我在 MDN 或类似网站上找不到任何关于此的信息。
该defer属性是明确的给我。
<script src="https://unpkg.com/petite-vue" defer init></script>
<!-- anywhere on the page -->
<div v-scope="{ count: 0 }">
{{ count }}
<button @click="count++">inc</button>
</div>
Run Code Online (Sandbox Code Playgroud) 所以我正在创建一个Vuejs应用程序,我正在尝试在组件安装上获取firebase数据.这是有效的,但我尝试将值写入vuejs数据属性.为此,我只会this.property = snapshot.val();在firebase函数内部调用(参见下面的代码),但这不起作用:this is undefined
所以我的代码就是:
export default {
data() {
return {
imageList: "No images!"
}
},
mounted() {
if (!firebase.apps.length) {
// Initialize Firebase
var config = {
...
};
firebase.initializeApp(config);
var database = firebase.database();
var ref = database.ref("images").orderByChild("date");
firebase.database().ref("images/").once('value').then(function(snapshot) {
this.imageList= snapshot.val();
});
}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试this.imageList= snapshot.val();使用变量来调用函数外部以存储值,并且'this'不再是未定义的,但数据不存在,因为请求尚未完成.
所以基本上我想得到snapshot.val(); 进入this.imageList!
提前致谢.
javascript firebase vue.js firebase-realtime-database vue-component
我使用plotly.js-(basic-dist-min) v1.52.2和angular-plotly.js v1.5.0一个角8项目中。一切正常,唯一的例外是如果我返回“图形对象”,那么来自 getter 的数据数组和布局,网页会冻结。我想这是因为 plotly 经常调用 getter,但我无法检查,因为 devtools 也被冻结了。getter 很简单:
public get chart(): { data: any, layout: any } | null {
const data = computeSomeChartData(); // just one array filter
return { data: [...], layout: {...} }
// return null if no data
}
Run Code Online (Sandbox Code Playgroud)
模板看起来像:
<plotly-plot
[data]="chart.data"
[layout]="chart.layout"
[config]="{ displayModeBar: false }"
[useResizeHandler]="true"
width="100%"
height="100%"
*ngIf="chart !== null"
></plotly-plot>
Run Code Online (Sandbox Code Playgroud)
如何将图表保留为吸气剂,但防止页面冻结?(最好没有超时或类似的东西。)