gpt4 book ai didi

javascript - Alasql 未定义

转载 作者:行者123 更新时间:2023-11-30 00:06:20 26 4
gpt4 key购买 nike

我似乎无法定义 Alasql,我已经通过节点安装了它,并且我相当确定它已正确安装,但是每当我加载我的前端时。我不是 100% 确定哪里出了问题,任何帮助将不胜感激!

require is not defined at Scope.$scope.exportData





$scope.exportData = function () {

var mystyle = {
sheetid: 'Account sheet',
headers: true,
caption: {
title:'My Big Table',
},
style:'background:#00FF00',
column: {
style:'font-size:30px'
},
columns: [
{columnid:'Date'},
{columnid:'Description'},
{columnid:'Due'},
{columnid:'Charged £'},
{columnid:'Received £'},
{columnid:'Balanced £'},
{
columnid:'name',
title: 'Number of letters in name',
width: '300px',
cell: {
value: function(value){return value.length}
}
},
],
row: {
style: function(sheet,row,rowidx){
return 'background:'+(rowidx%2?'red':'yellow');
}
},
rows: {
},
cells: {
2:{
2:{

}
}
}
};

$scope.exportData = function () {
var alasql = require('alasql');
alasql('SELECT * INTO XLS("report.xls",?) FROM ?',[mystyle,records]);
};

最佳答案

1 - 来自自己angularjs readme :

Please include the file normally and not via requireJS. Please include alasql before requireJS to avoid issue of "Mismatched anonymous define() module". This issue is with requireJS.

2 - 在使用 grunt 构建我的项目时出现“alasql is undefined”。所以我必须在我的 jshint 文件中的“globals”部分下包含 alasql:

{
.
.
.
"globals": {
"angular": false,
"confirm": false,
"console": false,
"alert": false,
"alasql": false
}
}

PS:我建议您导出为“.xlsx”而不是“.xls”。微软现在refusing to open those files .

关于javascript - Alasql 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38374053/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com