我似乎无法定义Alasql,我已经通过节点安装了它,而且我相当肯定,无论何时加载我的前端,它都是安装得很好的。我不能百分之百确定哪里出了问题,任何帮助都是非常感谢的!
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]);
};发布于 2016-08-03 17:55:23
从他们自己的angularjs自述
请包括文件正常,而不是通过requireJS。请在requireJS之前包括alasql,以避免出现“不匹配的匿名定义()模块”。这个问题与requireJS有关。
当我使用grunt来构建我的项目时,我有"alasql是未定义的“。因此,我必须在jshint文件中的"globals“部分中包括alasql:
{
.
.
.
"globals": {
"angular": false,
"confirm": false,
"console": false,
"alert": false,
"alasql": false
}
}PS:我建议您导出到".xlsx“而不是".xls”。微软现在是拒绝打开那些文件。
https://stackoverflow.com/questions/38374053
复制相似问题