简体   繁体   English

使用jQuery word export插件时出现未定义的错误

[英]Undefined error when using jQuery word export plugin

I am using a SAP UI5 application and trying to export table data into a word document but get an undefined error in document. 我正在使用SAP UI5应用程序并尝试将表数据导出到word文档中,但在文档中得到未定义的错误。 I am using jquery.wordexport.js as in example here . 我在这里使用jquery.wordexport.js My html code is as defined below 我的html代码如下定义

<head>
    <script src="FileSaver.js"></script> 
    <script src="jquery.wordexport.js"></script> 
    <script>
        sap.ui.localResources("odataservice");
        var app = new sap.m.App({
            initialPage:"idodataservice1"
        });
        var page = sap.ui.view({
            id: "idodataservice1", 
            viewName: "odataservice.odataservice", 
            type: sap.ui.core.mvc.ViewType.XML
        });
        app.addPage(page);
        app.placeAt("content");
    </script>
</head>
<body class="sapUiBody" role="application">
    <div id="content">Hi</div>
</body>

The div content is having a table shown on screen and is not empty, on click of button I am calling below method div内容显示在屏幕上并且不是空的,点击按钮我在下面调用方法

onPressExport: function() {
    jQuery(document).ready(function($) {
        $("content").wordExport();
    });
},

I have added both files at the root level and export document does come in but with text 'undefined' written inside it. 我已经在根级别添加了两个文件,并且导出文档确实已经进入,但是文本内部写有“未定义”文本。 Tried checking the id at runtime in console and tried different sub div Ids as well but still get undefined error. 尝试在运行时在控制台中检查id并尝试不同的子div ID但仍然得到未定义的错误。 Please suggest what could be wrong here or am I missing something. 请建议这里可能出现的问题,或者我错过了什么。

You don't need the 'ready' event inside the OnPressExport : 您不需要OnPressExport的'ready'事件:

onPressExport: function() {
    $("content").wordExport();
},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM