我正在编写C代码,我正在分析一些数据.我已将程序设置为仅处理100个数据输入.当它有超过100个输入时,它会产生分段错误.我想创建一种方法,以便当输入数量超过100时,将警告用户并终止程序.我知道如何通过简单的方式从main函数中完成它return 0,但是我是远离main的多个函数调用而且很难做到这一点,即使return 0在这个函数中也会保持循环.
是否有任何直接的方法来终止整个程序而不是主要的?
我有一个(不可更改的)DOM结构如下:
<div id="indexVue">
...
<div id="childVue">
...
</div>
...
</div>
Run Code Online (Sandbox Code Playgroud)
还有两个js文件:
index.js:
var child = require('childVue');
module.exports = new Vue({
el: '#indexVue',
...
});
Run Code Online (Sandbox Code Playgroud)
childVue.js:
module.exports = new Vue({
el: '#childVue',
methods: {
something: function(){
// Parent data needed here ...
},
...
}
});
Run Code Online (Sandbox Code Playgroud)
如图所示,我需要indexVuein 的数据childVue.有没有办法把它传递给它?我试图将它传递给一个函数(v-on="click: childFunction($data)"),但只有(逻辑上)返回数据属性,childVue而不是从indexVue.
谷歌没有真正帮助,因为Vue没有充分记录.
真正的文件和DOM结构更大更复杂,但我的问题所必需的只是这些文件.
此外,我不允许在这里使用jQuery,这将使它成为秒的任务.
假设我有这个代码:
export class ProductsListComponent {
@Output() onProductSelected: EventEmitter<Product>;
constructor() {
this.onProductSelected = new EventEmitter();
}
}
Run Code Online (Sandbox Code Playgroud)
这是一些用法示例EventEmitter。我不明白为什么首先我们声明 onProductSelect 明确指出它EventEmitter携带 Product 实例,然后我们仅使用new EventEmitter(). 为什么不new EventEmitter<Product>()?
我认为在 C# 中我必须采用第二种方式,因为否则如果EventEmitter是通用的,它就无法编译。为什么 TypeScript 不需要这样?
//编辑:
进一步澄清我的问题。有什么区别:
@Output() onProductSelected: EventEmitter<Product>;
this.onProductSelected = new EventEmitter();
Run Code Online (Sandbox Code Playgroud)
和
@Output() onProductSelected: EventEmitter;
this.onProductSelected = new EventEmitter();
Run Code Online (Sandbox Code Playgroud) 我想在用户安装使用NSIS生成的EXE后在Windows 7中创建新服务.我试过这段代码SimpleSC::StartService "TestService" '' 15和这段代码,
SimpleSC::InstallService "MyService" "My Service Display Name" "16" "2" "E:\utilisateur\xxx.exe" "" "" ""但都没有工作; 它显示未找到插件,无法调用SimpleSC :: StartService
我正在通过HTTP向服务器发出请求,以查看是否存在使用特定电子邮件的用户。
function userExists(id) {
return makeHttpRequestToServer(id)
.then((response) => {
if (response === 200) {
// User exists in the database
} else if (response === 404) {
// User does not exist in the database
}
});
}
Run Code Online (Sandbox Code Playgroud)
我不确定应该如何处理resolve/ reject调用:
resolve()何时在数据库中找到用户,以及reject()何时在数据库中找不到用户?resolve(true)何时在数据库中找到用户,以及accept(false)何时在数据库中找不到用户?javascript ×2
angular ×1
c ×1
dom ×1
exit ×1
generics ×1
nsis ×1
promise ×1
typescript ×1
vue.js ×1