我想创建一个要导入Main.js文件的模块数组。我如何访问包含导入模块的对象?
编辑为了进一步解释,我将多个类导入到Main.js包含主类的文件中。这些类中的每一个都来自它们自己的单独文件,给我这样的导入语句:
import Header from './features/Header.js';
import ImageStrip from './features/ImageStrip.js';
import AreaChart from './features/AreaChart.js';
import Axes from './features/Axes.js';
Run Code Online (Sandbox Code Playgroud)
是否有一个 JavaScript 对象包含导入的模块,例如类似的东西[ Header, ImageStrip, AreaChart, Axes ]?或者是否可以创建一个?
我在用:
html {
scroll-behavior: smooth;
}
Run Code Online (Sandbox Code Playgroud)
实现平滑滚动到 html 锚标记。我还使用css 中的scroll-snap-type和启用垂直滚动捕捉,如下面的代码所示。scroll-snap-align问题是我无法让这两种行为都起作用。要启用滚动捕捉,我需要设置包含的高度div。这似乎禁用了 html 锚标记的平滑滚动。您可以在下面的代码片段中全屏进行试验。如果您删除height: 100vh;下面的代码片段,页面将平滑滚动到锚点,但不会快速滚动。如果包含它,页面将快速滚动,但会跳转到锚点,而不是平滑滚动。
html {
scroll-behavior: smooth;
}
Run Code Online (Sandbox Code Playgroud)
html {
scroll-behavior: smooth;
}
main {
height: 100vh;
overflow: scroll;
scroll-snap-type: y mandatory;
}
section {
height: 400px;
scroll-snap-align: start;
}
nav {
position: fixed;
top: 0;
color: white;
width: 100%;
}
li {
display: inline-block;
list-style-type: none;
}
a:visited {
color: white;
}
.one {
background-color: red;
}
.two {
background-color: blue; …Run Code Online (Sandbox Code Playgroud)我无法在画布中创建多个剪切路径。使用此代码,如果 i=1,我的剪切路径可以正常工作。对于 i>1,我仅在路径重叠时看到剪切。否则,画布上不会绘制任何内容。
function draw() {
var ctx = document.getElementById('canvas').getContext('2d');
for (var i = 0; i < 5; i++) {
ctx.beginPath();
var x = 25 + 25 * i; // x coordinate
var y = 75; // y coordinate
var radius = 20; // Arc radius
var startAngle = 0; // Starting point on circle
var endAngle = Math.PI * 2; // End point on circle
var anticlockwise = true; // clockwise or anticlockwise
ctx.arc(x, y, radius, startAngle, endAngle, anticlockwise); …Run Code Online (Sandbox Code Playgroud) 如果您单击此示例中的红色按钮:
https://bl.ocks.org/interwebjill/fe782e6f195b17f6fe6798a24c390d90
您可以看到图表平移,使圆圈位于中心,然后放大到指定级别(重新单击按钮缩小)。以这种方式翻译然后放大会在左侧留下一个我宁愿没有的空白。我如何更改代码以便图表先缩放然后转换为中心,以便图表中没有这个间隙?
我曾尝试在缩放定义和 zoomToExtent 函数中颠倒比例和平移的顺序,但效果没有什么不同。
在 SvelteKit 中,我想在不使用 SSR 加载函数的情况下访问 page.params,因为我只想让客户端呈现。有没有办法在没有SSR加载功能的情况下访问page.params?
我正在使用此代码来生成每小时的范围datetime:
from datetime import datetime, timedelta
def daterange(start_date, end_date):
# timedelta only has days and seconds attributes
for n in range(int ((end_date - start_date).seconds/3600 + 1)):
yield start_date + timedelta(n)
start_date = datetime(2013, 1, 1, 14, 00)
end_date = datetime(2015, 6, 2, 5, 00)
for single_date in daterange(start_date, end_date):
print single_date.strftime("%Y-%m-%d %H:%M")
Run Code Online (Sandbox Code Playgroud)
但是我得到了意外的结果:
2013-01-01 14:00
2013-01-02 14:00
2013-01-03 14:00
2013-01-04 14:00
2013-01-05 14:00
2013-01-06 14:00
2013-01-07 14:00
2013-01-08 14:00
2013-01-09 14:00
2013-01-10 14:00
2013-01-11 14:00
2013-01-12 14:00
2013-01-13 …Run Code Online (Sandbox Code Playgroud)