我正在使用Vite构建一个多页面应用程序(从 Webpack 迁移)。
要在开发服务器中打开登录页面,我必须转到:localhost:3010/login.html
是否可以调整 Vite 配置以提供 login.html,其 URL 为:(localhost:3010/login不带 .html)?
// vite.config.js excerpt
export default {
build: {
rollupOptions: {
input: {
index: new URL('./index.html', import.meta.url).pathname,
login: new URL('./login.html', import.meta.url).pathname,
}
}
},
server: {
port: 3010,
proxy: {
'/api': 'http://localhost:5000/',
},
},
};
Run Code Online (Sandbox Code Playgroud) 我根本无法理解为什么它会给出这个错误.
这是我在chrome控制台上测试的内容:
> var mySet;
<- undefined
> mySet = new Set;
<- Set {}
> mySet.add('foo', 'bar', 'baz') // Worked as expected
<- Set {"foo"} // just the first argument was added
> ['bar', 'baz'].forEach(mySet.add)
X-> VM1529:1 Uncaught TypeError:
Method Set.prototype.add called on incompatible receiver undefined(…)
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我需要与以下相同的结果:
var array = [1, 2, 3, 5, 7];
var top = array.pop();
Run Code Online (Sandbox Code Playgroud)
问题是pop从数组中删除元素.要解决这个问题,我添加了另一行:
array.push(top);
Run Code Online (Sandbox Code Playgroud)
但这让我感到烦恼,我在这个项目中做了四到五次,直到现在.有没有更好的办法?
在我的页面中,我有两个相同宽度的表,它们都进行水平滚动.当每个表滚动时,我需要将两个表设置为相同的位置.
实际上,我的代码是:
var scrollA = $('#scrollA'),
scrollB = $('#scrollB');
scrollA.on('scroll', function() {
scrollB[0].scrollLeft = scrollA[0].scrollLeft;
});
Run Code Online (Sandbox Code Playgroud)
有用.问题是,在某些情况下,加载的数据足以使浏览器和滚动事件变慢.
然后,我正在努力改善那些情况下的用户体验.
我做了这个片段,我尝试使用以下__defineSetter__功能Object:
var elementA = { scrollLeft: 30 },
elementB = { scrollLeft: 30 };
elementA.__defineSetter__('scrollLeft', val => elementB.scrollLeft = val);
elementA.scrollLeft += 5;
console.log(elementA.scrollLeft + ' == ' + elementB.scrollLeft);Run Code Online (Sandbox Code Playgroud)
但是你可以看到运行的片段,将其设置undefined到elementA.scrollLeft和NaN到elementB.scrollLeft.
我想在这里给你一些指导,谢谢你的时间.
上下文:我正在编写一个用户表单,它将有一些过滤器来运行一个过程并用返回值填充一个工作表.
我的一个过滤器出了问题.我能够以简化版重现我的问题.此过滤器应根据所选的组合框选项将数据加载到列表框中:
我没有什么重命名,组分包括:UserForm1,ListBox1和ComboBox1.
我的破码(评论):
Option Explicit
'sub that fill data in the list box columns
Sub loadList(list As ListBox, id As Integer)
list.Clear
If (id > 0) Then
list.AddItem
list.Column(0, 0) = "Item 1"
list.AddItem
list.Column(0, 1) = "Item 2"
End If
End Sub
'event that will trigger the loadList sub
Private Sub ComboBox1_Change()
Dim id As Integer
id = ComboBox1.ListIndex
loadList ListBox1, id
End Sub
'the combo options is auto initialized …Run Code Online (Sandbox Code Playgroud) 我尝试使用以下命令导入 matplotlib:
import matplotlib.pyplot as plt
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误:
ImportError:无法从“matplotlib”导入名称“animation”(C:\ Users \ David \ AppData \ Roaming \ Python \ Python37 \ site-packages \ matplotlib_ init _.py)。
我删除并重新安装了 matplotlib,我尝试安装旧的 matplotlib 版本。
我刚遇到这种情况:
var testing = 'thing 1';
function func() {
console.log(testing);
var testing = 'thing 2';
console.log(testing);
}
func();Run Code Online (Sandbox Code Playgroud)
我希望上面的代码能够记录'thing 1'下来'thing 2'.但是,'thing 1'永远不会记录.
起初我认为可能是静态函数的某些行为将testing变量保留到其范围,因此它undefined代替'thing 1'.
但是,如果我自己的解释(最初看起来正确)是有效的,那么我不确定它是否真的是一个静态函数.
为什么testing变量在undefined里面func?为什么无法func访问全局变量?还有其他类似的情况吗?
PS:我试图找到一个骗局,但失败了.
我有一个Participant可以有两种类型的模型:Establishment或Provider:
export class Participant {
id?: number;
name?: string;
ltype: 'Provider' | 'Establishment';
get isProvider(): boolean {
return this.ltype === 'Provider';
}
get isEstablishment(): boolean {
return this.ltype === 'Establishment';
}
get opposite(): string {
if (this.ltype === 'Provider') {
return 'Establishment';
}
return 'Provider';
}
}
Run Code Online (Sandbox Code Playgroud)
一切都很好,没有错误,直到这里.但是当我尝试初始化它时:
const filter: Participant = {
ltype: 'Provider'
};
Run Code Online (Sandbox Code Playgroud)
它抛出:
输入"{ltype:"Provider"; }'不能分配给'参与者'类型.
类型'{ltype:"Provider"中缺少属性'isProvider'; }".
我无法摆脱上述错误.
我认为这不重要,但此代码适用于Angular 4应用程序.
提前致谢.
javascript ×5
animation ×1
excel ×1
excel-vba ×1
listbox ×1
matplotlib ×1
performance ×1
reactjs ×1
scroll ×1
typescript ×1
userform ×1
vba ×1
vite ×1