小编Raf*_*ado的帖子

React-Intl如何从变量切换语言环境和消息

我正试图弄清楚如何使用React-Intl更改语言.这是我的第一个React App,它是用create-react-app制作的,我没有使用Redux和Flux.

在我的index.js中,我有以下代码:

import React from 'react';
import ReactDOM from 'react-dom';
import TodoApp from './components/TodoApp';
import registerServiceWorker from './registerServiceWorker';
import './index.css';

// Bootstrap CSS libraries
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';

import { IntlProvider, addLocaleData } from 'react-intl';
import intlEN from 'react-intl/locale-data/en';
import intlES from 'react-intl/locale-data/es';
import intlMessagesES from './i18n/locales/es.json';
import intlMessagesEN from './i18n/locales/en.json';

addLocaleData([...intlEN, ...intlES]);

/* Define your translations */
let i18nConfig = {
    locale: 'es',
    messages: intlMessagesES
};

let changeLanguage = (lang) => {
    i18nConfig = { locale: lang, messages: …
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6 reactjs react-intl create-react-app

10
推荐指数
2
解决办法
1万
查看次数

如何使用 jspdf-Autotable 在表格中添加自定义最后一行

我正在尝试使用jspdfjspdf-Autotable构建一个小型应用程序,但我不知道如何使用现有表中的另一个变量值创建自定义最后一行。

到目前为止我刚刚所做的是:

  doc.autoTable({ 
    body: concepts,
    columns: [{ header: 'Concept', dataKey: 'name' }, { header: 'Amount', dataKey: 'amount' }],
    didDrawPage: function (data) {
        let rows = data.table.body;
        rows.push({ 
          content: 'Total = ' + total,
          colSpan: 2
        });
        if (data.row.index === rows.length - 1) { doc.setFillColor(239, 154, 154); }
    }
  });
Run Code Online (Sandbox Code Playgroud)

我很确定我对如何面对这个问题感到困惑。total带有一个数字值,但我想将其打印在一个自定义的最后一行中,但在表格内,就像 Excel 规则一样。

任何建议都会有帮助!谢谢。

javascript jspdf jspdf-autotable

3
推荐指数
1
解决办法
5355
查看次数