在我的Spring 3.0应用程序中,我有一些资源/WEB-INF/dir.在运行时,我需要它们中的InputStream一些(或其他类型).我怎样才能找回它们?是否可以将它们作为正常注射Resource?
我是VueJS的新手,我收到Vue的警告,
[Vue warn]: You may have an infinite update loop in a component render function.
Run Code Online (Sandbox Code Playgroud)
当我在V-bind:style中使用V-for变量时,这是一个例子:在模板中:
<div v-for="item in model.items" v-bind:class="test(item.result)">
{{item.id}}
</div>
Run Code Online (Sandbox Code Playgroud)
在脚本中:
data() {
return {
accept: false,
not_accept: false,
};
},
methods: {
test(result) {
if (result == 'accept') {
this.accept = true;
this.not_accept = false;
} else if (result == 'Not accept') {
this.accept = false;
this.not_accept = true;
} else {
console.log(result);
}
return {
success: this.accept,
danger: this.not_accept,
};
},
},
Run Code Online (Sandbox Code Playgroud) 我已经使用webpack的代码拆分功能将我的应用程序拆分为多个块,以便在用户访问我的网页时不会下载整个应用程序包.
某些路由所需的块可能相当大,并且可能需要花费相当多的时间来下载.这很好,除非用户在单击内部链接时不知道页面实际上正在加载,所以我需要以某种方式显示加载动画或其他东西.
我的路由器配置如下:
[
{
path: '/',
component: () => import(/* webpackChunkName: 'landing' */ './landing.vue'),
},
{
path: '/foo',
component: () => import(/* webpackChunkName: 'main' */ './foo.vue'),
},
{
path: '/bar',
component: () => import(/* webpackChunkName: 'main' */ './bar.vue'),
},
]
Run Code Online (Sandbox Code Playgroud)
Vue.js指南中的高级异步组件显示了在解析组件时如何显示特定的"加载"组件 - 这正是我所需要的,但它也说:
请注意,当在vue-router中用作路由组件时,将忽略这些属性,因为在路由导航发生之前会先解析异步组件.
如何在vue-router中实现这一点?如果这是不可能的,延迟加载的组件对我来说几乎没用,因为它会给用户带来糟糕的体验.
我试过这样做,但它不起作用.
// filter.js
export default {
converTimestamp: function (seconds) {
var date = new Date(seconds * 1000);
return date.toDateString();
}
};
// main.js
import customFilters from './store/filters';
Run Code Online (Sandbox Code Playgroud) 我想知道如何在Vuex中使用async/await动作.所述文档提供此语法作为一个例子:
actions: {
async actionA ({ commit }) {
commit('gotData', await getData())
},
async actionB ({ dispatch, commit }) {
await dispatch('actionA') // wait for `actionA` to finish
commit('gotOtherData', await getOtherData())
}
}
Run Code Online (Sandbox Code Playgroud)
按照这个例子,我有:
import Vue from 'vue';
import Vuex from 'vuex';
import * as firebase from 'firebase';
Vue.use(Vuex);
export const store = new Vuex.Store({
state: {
// other state vars here
resource: null
},
mutations: {
// saveValues
setResource(state, payload) {
state.resource = payload;
}
},
actions: …Run Code Online (Sandbox Code Playgroud) .scroll {
position: absolute;
left: 0;
top: 0;
background: yellow;
overflow: auto;
max-height: 100px;
}Run Code Online (Sandbox Code Playgroud)
<div class="scroll">
<div>123456789</div>
<div>123456789</div>
<div>123456789</div>
<div>123456789</div>
<div>123456789</div>
<div>123456789</div>
<div>123456789</div>
</div>Run Code Online (Sandbox Code Playgroud)
火狐79
当 div 的高度溢出时,Firefox 会显示垂直滚动条,而不增加 div 的宽度来容纳它,从而导致显示水平滚动条。
铬84
Chrome 按预期增加了 div 的宽度,并且不显示水平滚动条。
如何让 Firefox 像 Chrome 一样工作?
限制条件:
scroll需要与其内容相匹配。我尝试过的:
min-width: 0/auto首先,我检查并打开历史模式,我vue-router像这样调用:
const router = new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: routes,
});
Run Code Online (Sandbox Code Playgroud)
我当前所在的路线是/page/item/8,并且我正在重定向到/page/item/9。目前,网址已更改,但页面不会重新呈现,使我保持之前的相同视图。
这个重定向是这样完成的:
this.$router.push({ name: 'PageItem', params: { itemId: '9' }}).catch(err => {
// Stop Vue.router throwing an error if a user clicks on a notification with the same route.
if (err.name !== 'NavigationDuplicated') {
this.$logger.debug.log(err);
}
});
Run Code Online (Sandbox Code Playgroud)
有问题的路线如下:
import PageWrapper from '@/layouts/PageWrapper';
export default [
{
path: '/page',
name: 'page',
component: PageWrapper,
children: [
... Other Routes ...
{
component: () …Run Code Online (Sandbox Code Playgroud) Grid类的文档说明:
从Windows 10开始,Grid定义了新的边框属性,使您可以在不使用其他Border元素的情况下在网格周围绘制边框.新属性是Grid.BorderBrush,Grid.BorderThickness,Grid.CornerRadius和Grid.Padding.
这会使Border类多余吗?为什么我会永远想使用边界,如果我可以做同样的事情用一个网格,并在网格的方式铺陈的孩子,如果我这样选择?
编辑
我一般都同意Bart的回答,但我想谈谈一些事情.
首先,其他布局控件(如StackPanel)确实具有类似Border的属性,例如BorderBrush,BorderThickness和CornerRadius,因此Grid不是获得这些新特权的唯一布局控件.但它们不是Border类提供的附加属性(或者与Border类有任何关系).
其次,我也认为如果我只想在像图像这样的简单控件中添加边框,那么使用像Grid这样的复杂布局控件会有些过分.但是,这些布局控件肯定会进行优化,如果它们只包含一个没有任何特殊布局约束的子节点,那么对布局渲染速度的任何影响都可以忽略不计.因此,当它只有一个子节点时,使用Grid而不是Border应该不会影响性能.
最后,我决定找出Grid如何实现边框外观.我创建了一个包含带边框和单个Rectangle子节点的Grid的简单页面,如下所示:
<Grid Background="Red" BorderBrush="Blue" BorderThickness="10">
<Rectangle Width="50" Height="50" HorizontalAlignment="Left" VerticalAlignment="Top" Fill="Yellow"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
使用以下渲染:
在检查实时可视树时,Grid类不会向可视树添加任何其他元素以使边框显示:
我怀疑它用于创建边框外观的任何机制都与Border控件的相同(也许它在合成层中创建了一个额外的Visual).
所以我并不是真的相信"更简单"的边框控件会更好用,因为它看起来像Grid控件已经非常高效.我看不到网格控件的任何证据,为视觉树添加任何额外的开销(与边框相比,可以实现相同的效果).
到目前为止,我能想到为什么我应该使用Border而不是Grid的唯一原因是表达意义.很明显边框控件的作用是,在单个元素周围添加边框.网格是一种布局控件,用于在网格中布置子元素(正如它所发生的那样,它还能够在其子元素周围添加边框作为额外的奖励).
MSDN列出了样式和模板TextBox类在这里.我可以通过创建这样的ResourceDictionaryin 来覆盖这些主题资源App.xaml:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="TextBoxPlaceholderTextThemeBrush" Color="Yellow"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
但这会影响TextBox我的应用中的每一个.如何仅为特定元素设置此主题?
我试图把这个字典中Page.Resources,甚至TextBox.Resources对TextBox,我想将它应用到,但它不工作.
我真的不想重新定义Template刚改变这个属性.
编辑 Heena的答案很接近,但我还想为明暗主题设置不同的颜色,因为我的文本框具有透明的背景颜色.
我设法通过保持Foreground="{ThemeResource TextBoxPlaceholderTextThemeBrush}"作为其一部分来实现这一点Template(换句话说,模板完全是MSDN的默认模板),然后在页面资源中指定:
<Page.Resources>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="TextBoxPlaceholderTextThemeBrush" Color="Blue"/>
</ResourceDictionary>
...
</ResourceDictionary.ThemeDictionaries>
</Page.Resources>
Run Code Online (Sandbox Code Playgroud)
但现在这意味着我必须ControlTemplate在我的页面资源中为文本框设置一个巨大的样式设置器,这只是默认的默认复制品!
这是否与如何TextBoxPlaceholderTextThemeBrush从内部解决ControlTemplate?即它发现我的自定义主题词典的原因是因为它ControlTemplate是在同一资源字典中定义的?
应该怎么做?我应该只是将文本框子类化,以便将所有XAML移动到另一个文件(即使它仅用于一个文本框)?
每当我使用Windows.Web.Http.HttpClient类发出HTTP请求时,我总是处理这样的网络异常:
HttpResponseMessage response;
try
{
response = await httpClent.GetAsync(new Uri("http://www.microsoft.com"));
}
catch (Exception e)
{
// Most likely a network exception.
// Inspect e.HResult value to see what the specific error was.
}
Run Code Online (Sandbox Code Playgroud)
但是现在我将捕获所有异常,而不仅仅是网络异常,特别是如果try块不仅包含httpClient.GetAsync调用.
各种异常HRESULT已经在ABI层自动转换为适当的托管类型(例如,E_OUTOFMEMORY被投射到System.OutOfMemoryException),那么为什么网络异常不会以类似的方式进行投影?
c# windows-runtime windows-8.1 winrt-httpclient windows-phone-8.1
vue.js ×5
vue-router ×2
windows-8.1 ×2
xaml ×2
async-await ×1
c# ×1
css ×1
firefox ×1
html ×1
java ×1
javascript ×1
node.js ×1
resources ×1
spring ×1
uwp ×1
vuejs2 ×1
vuex ×1
webpack ×1
windows-10 ×1