我试图遵循文档并创建vite.config.js
如下:
const config = {
outDir: '../wwwroot/',
proxy: {
// string shorthand
'/foo': 'http://localhost:4567',
// with options
'/api': {
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
}
}
};
export default config;
Run Code Online (Sandbox Code Playgroud)
并尝试通过以下调用对其进行测试:
fetch('/foo');
fetch('/api/test/get');
Run Code Online (Sandbox Code Playgroud)
我本来期望有实际的请求,http://localhost:4567/foo
但http://jsonplaceholder.typicode.com/test/get
它们都以我的开发服务器作为源,如下所示:http://localhost:3000/foo
和http://localhost:3000/api/test/get
难道是我理解错了?代理应该如何工作?
我还在 Vite 存储库中创建了一个问题,但它已关闭,而且我不明白结束评论。
我正在尝试创建一个包含大量图层的动画图片.为了在不同的屏幕上使用正确比例的图像,我使用cover
css属性值(我已经object-fit
为图像和background-size
背景图像尝试了它).这就是为什么我在宽屏幕上的图像被浏览器歪曲的原因.
问题是我的图层在动画过程中被变换(主要是旋转和移动),因此有时会看到裁剪后的图像.
请参阅下面的示例.
如何预防?还是有其他一些技巧?
body {
margin: 0;
padding: 0;
/*Just to imitate wide screen*/
width: 1000px;
height: 450px;
}
#container {
width: 100%;
height: 100vh;
/*Just to imitate wide screen*/
height: 100%;
overflow: hidden;
position: relative;
}
.layer {
height: 100%;
position: absolute;
width: calc(100% + 20px);
}
.layer img {
height: 100%;
width: 100%;
object-fit: cover;
}
.gulls {
animation: gulls ease-in-out 13s infinite alternate;
}
@keyframes gulls {
from {
transform: …
Run Code Online (Sandbox Code Playgroud)我有一个复杂属性的类:
public class A
{
public B Prop { get; set; }
}
public class B
{
public int Id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我添加了一个验证器:
public class AValidator : AbstractValidator<A>
{
public AValidator()
{
RuleFor(x => x.A.Id).NotEmpty().WithMessage("Please ensure you have selected the A object");
}
}
Run Code Online (Sandbox Code Playgroud)
但在A.Id的客户端验证期间,我仍然有一个默认的val消息:"'Id'不能为空".如何从验证器将其更改为我的字符串?
我正在开发一个小型库,用于显示 vue 3 的通知/toast。我的想法是在插件注册期间为我的通知附加一个不可见的容器。因此最终用户不应该关心渲染该区域。有可能吗?
我当前的插件如下所示:
export const plugin = {
install: (app: App, options?) => {
options = reactive(options || defaultOptions);
app.provide(symbol, instance);
app.component('vue3-notification', Notification);
app.component('vue3-notifications', Overlay);
console.log('app', app); // app._component is null at this point
var test = Overlay.render({ notifications: instance });
console.log('test', test); // how to attach Overlay component to app?
}
};
Run Code Online (Sandbox Code Playgroud)
似乎安装插件后,vue 根容器还不可用。我设法渲染我的组件,提供所需的依赖项(至少我希望如此,它在最后一行记录到控制台),但我不知道如何安装它并与主应用程序集成。
我想从插件自动渲染的覆盖组件如下所示:
<div class="notifications-overlay">
<Teleport to="body">
<vue3-notification
v-for="(n, index) in notifications.stack.value"
:key="n.id"
v-bind="n"
v-bind:hide="() => hide(n.id)"
></vue3-notification>
</Teleport>
</div>
Run Code Online (Sandbox Code Playgroud)
并且它有固定的位置:
.notifications-overlay {
position: fixed; …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在来自 nhibernate envers 的修订实体和包含用户名的列表之间执行连接。我想返回一个命名元组列表。
这是我的代码
public IEnumerable<(Societa company, DateTime datetime, string userName)> CompanyHistory()
{
IAuditReader auditReader = this._session.Auditer();
var revison = auditReader.CreateQuery().ForHistoryOf<Societa, RevisionEntity>().Results();
IList<Persona> user = _session.QueryOver<Persona>().List();
var query = revison.Join(user,
rev => rev.RevisionEntity.IdUtente,
us => us.Id,
(rev, us) => new
{
Oggetto = rev.RevisionEntity,
DataModifica = rev.RevisionEntity.RevisionDate.ToLocalTime(),
NomeUtente = us.NomePersona
}).ToList();
}
Run Code Online (Sandbox Code Playgroud)
但现在我没有找到返回元组的方法
我也试试
(ele, p) => new (OutputGA Oggetto, DateTime DataModifica, string NomeUtente)
{
Oggetto = ele.RevisionEntity,
DataModifica = ele.RevisionEntity.RevisionDate.ToLocalTime(),
NomeUtente = p.NomePersona
}).ToList();
Run Code Online (Sandbox Code Playgroud)
但我得到了 …
我想使用https://github.com/alexcrack/angular-ui-notification进行通知。我所有的控制器都需要它们。是否可以在我的所有控制器中注入“通知”(或“$log”或其他内容)?
是否有意义指定具体类型的ToList<T>()
,AsEnumerable<T>()
等等的方法呢?
会.ToList<SomeClass>()
执行得更快.ToList()
吗?
如何在电子邮件或电话号码中编写允许为空的验证规则
RuleFor(x => x.Email).NotEmpty().WithMessage(localizationService.GetResource("ContactUs.Email.Required"));
RuleFor(x => x.PhoneNumber).NotEmpty().WithMessage(localizationService.GetResource("Products.MakeAnOffer.PhoneNumber"));
Run Code Online (Sandbox Code Playgroud) asp.net ×2
c# ×2
validation ×2
vuejs3 ×2
.net ×1
angularjs ×1
asp.net-mvc ×1
css ×1
generics ×1
html ×1
http-proxy ×1
linq ×1
list ×1
nhibernate ×1
nopcommerce ×1
performance ×1
tuples ×1
vite ×1
vue.js ×1