首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jsReports assets节点jsReports

jsReports assets节点jsReports
EN

Stack Overflow用户
提问于 2021-09-10 22:02:50
回答 2查看 42关注 0票数 0

我正在尝试将css样式表作为资产添加到jsReport报告中。

代码语言:javascript
复制
  jsreport.render({
    template: {
      content: `

     
      <html>
      <link rel="stylesheet" type="text/css" href="/css/style.css">
          <head>
              <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
              <style>
                  {#asset /css/style.css}
              </style>
          </head>
          <body>
             ...
          </body>
      </html>

      `,
      
      engine: 'handlebars',
      recipe: 'html',
      assets: {
        allowedFiles: "static/**.js",
        publicAccessEnabled: true,
        searchOnDiskIfNotFoundInStore: true,
      },
    },
    data: newCart
  }).then((out) => {
    out.stream.pipe(res);
  }).catch((e) => {
    res.end(e.message);
  });

当我试图加载资产时,问题出在标签中。你知道该怎么做吗?提前感谢!:)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-09-27 08:27:46

我直接“解决”了在标签中粘贴css的问题,就像导入#asset时的问题一样。

这不是最好的解决方案,但它起作用了:)

票数 0
EN

Stack Overflow用户

发布于 2021-09-24 18:49:34

对于jsreportonline.net,我总是把资产放在第一行,所以也许下面这样的代码就行了。

代码语言:javascript
复制
    template: {
      content: `

      <style>
          {#asset /css/style.css @encoding=utf8}
      </style>     
      <html>
      <link rel="stylesheet" type="text/css" href="/css/style.css">
          <head>
              <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
          </head>
          <body>
             ...
          </body>
      </html>

      `,
      
      engine: 'handlebars',
      recipe: 'html',
      assets: {
        allowedFiles: "static/**.js",
        publicAccessEnabled: true,
        searchOnDiskIfNotFoundInStore: true,
      },
    },
    data: newCart
  }).then((out) => {
    out.stream.pipe(res);
  }).catch((e) => {
    res.end(e.message);
  });`
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69138398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档