我正在尝试创建这个在使用 map() 函数时运行良好的按钮:
{bands.events.map((group, i) => (
<tr key={i}>
<td>{group.start}</td>
<td>
{" "}
<button value={group.name} onClick={props.handleClickGroup}>
{group.name}
</button>
</td>
</tr>
))}
Run Code Online (Sandbox Code Playgroud)
但是,现在我想使用 react-table 按时间顺序过滤日期并启用其他功能,但是我似乎找不到添加此按钮并打印出按钮元素内本地 json 数据的方法。这是我的代码:
import React from "react";
import ReactTable from "react-table";
import "react-table/react-table.css";
var bands = require("../festivals/bands.json");
const FestivalTable = props => {
const columns = [
{
width: 200,
Header: "Time",
accessor: "start"
},
{
width: 300,
Header: "Artist Name",
accessor: "name",
Cell: cell => (
<button value={cell.accessor} onClick={props.handleClickGroup}>
{cell.accessor}
</button>
)
}
];
return ( …Run Code Online (Sandbox Code Playgroud) 我有这个 url http://localhost:8080/?london并且它需要加载到 london in <section id="london">.- 这是页面上的id 。我不能使用http://localhost:8080/#london,即使它会起作用!
为了让事情变得更复杂,我使用了一个 vue 框架,他们想要 master-origin/src/assets/js/mixins/Anchor.js 中的代码 - 因此我无法安装 jquery,必须是 vanilla js。
我试过了
var el = [];
el = window.location.href.split("/?")[1];
console.log("el: " + el);
el.scrollIntoView();
Run Code Online (Sandbox Code Playgroud)
哪个获取 /? 之后的值,但是当我尝试 scrollIntoView 时,我在控制台中收到此消息
类型错误:el.scrollIntoView 不是 VM10022 IE 工作中的函数:4
为什么?我正在关注 w3 学校指南https://www.w3schools.com/jsref/met_element_scrollintoview.asp
阅读文档http://openexchangerates.github.io/money.js/#fx.rates 它说你需要设置你的费率:
fx.base = "USD";
fx.rates = {
"EUR" : 0.745101, // eg. 1 USD === 0.745101 EUR
"GBP" : 0.647710, // etc...
"HKD" : 7.781919,
"USD" : 1, // always include the base rate (1:1)
/* etc */
}
Run Code Online (Sandbox Code Playgroud)
我完全得到,只有这些将是静态费率.它说要有动态速率你需要添加json api:
// Load exchange rates data via AJAX:
$.getJSON(
// NB: using Open Exchange Rates here, but you can use any source!
'http://openexchangerates.org/api/latest.json?app_id=[I hid this number]', function(data) {
// Check money.js has finished loading:
if (typeof fx !== …Run Code Online (Sandbox Code Playgroud) 我正在尝试打印联赛表,但团队部分位于嵌套对象中。如何连接到该对象,然后将它们放入team.name、team.crest的表格单元格中?我在这里看到了答案,但我似乎仍然无法打印出数组内的嵌套团队对象。
我尝试使用 :fields 属性,但它不起作用。我被困住了。
Data from console.log:
[{
draw: 1
goalDifference: 23
goalsAgainst: 14
goalsFor: 37
lost: 0
playedGames: 15
points: 43
position: 1
team: { "id": 64, "name": "Liverpool FC", "crestUrl": "http://upload.wikimedia.org/wikipedia/de/0/0a/FC_Liverpool.svg" }
}]
<template>
<b-container>
<b-table striped hover :fields="fields" :items="info">
<template v-slot:cell(name)="data">{{ data.value.team.name }}</template>
</b-table>
</b-container>
</template>
data() {
return {
fields: [
{ key: 'info.team.name', label: 'Team Name' },
],
info: [],
}
Run Code Online (Sandbox Code Playgroud) .appendChild对我不起作用,我要做的就是将我的javascript const bottomText中的html代码附加到没有jQuery的DOM中
const bottomText = `
<div class="bottom-text row">
<div class="column column-left">test
<p>xx%<span></span></p>
</div>
<div class="column column-right">
<p>test</p>
</div>
</div>
<hr>
`;
document.getElementById("piechart").appendChild(bottomText);
Run Code Online (Sandbox Code Playgroud)
和我的HTML
<body>
<div class="graphs">
<div class="pie-chart" id="piechart">
</div>
<script src="./js/pie.js"></script>
<script src="./js/linegraph.js"></script>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
为什么不起作用?与jQuery的作品,但对于这个项目,他们希望我只使用香草JS