所以我目前有:
App.html
<div>
<input on:input="debounce(handleInput, 300)">
</div>
<script>
import { debounce } from 'lodash'
export default {
data () {
name: ''
},
methods: {
debounce,
async handleInput (event) {
this.set({ name: await apiCall(event.target.value).response.name })
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
并得到错误Uncaught TypeError: Expected a function at App.debounce.这来自Lodash,所以看起来似乎没有来自Svelte的方法正在通过.
额外的额外编辑
我目前如何实现它的额外背景:
oncreate () {
const debounceFnc = this.handleInput.bind(this)
this.refs.search.addEventListener('input', debounce(debounceFnc, 300))
}
Run Code Online (Sandbox Code Playgroud) 我正在通过以下方式完成此任务:
context['card_type'] = self.kwargs['card_type']
context['role_line'] = self.kwargs['role_line']
context['sort_by'] = self.kwargs['sort_by']
Run Code Online (Sandbox Code Playgroud)
这对我来说似乎很直观.
如果我已经在网站上了 players/one/two/three
是否有一种已经预先构建的方法来获取one, two & three模板中使用的当前kwargs ?
编辑
urls.py
urlpatterns = patterns('',
url(
r'^$',
NationListView.as_view(),
name='index'
),
url(
r'^(?P<slug>[a-z-]*)/$',
NationDetailView.as_view(),
name='nation'
),
url(
r'^(?P<slug>[a-z-]*)/(?P<card_type>[a-z]*)/(?P<role_line>[a-z]*)/(?P<sort_by>[a-z0-9]*)/$',
NationDetailFilteredView.as_view(),
name='nation_filter'
),
)
Run Code Online (Sandbox Code Playgroud)
构建上下文的mixin
class CoreDetailFilteredMixin(object):
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super(CoreDetailFilteredMixin, self).get_context_data(**kwargs)
base_objects(context)
# Pull all the players that belong to the object_type
context['players'] = Player.objects.filter(
**{filters: context['object'].asset_id}
)
# Define …Run Code Online (Sandbox Code Playgroud) 当您扩展AdminSite到创建另一个管理站点时,如何才能反向匹配每个站点?似乎admin名称空间是硬编码的reverse('admin:index'),有没有办法提供自定义名称空间?
在webpack版本2.1.0-beta.28中,他们添加了(我正在使用2.2.0-rc.1):
添加
import()为代码拆分构造。应该使用它,而不是System.import尽可能使用它 。System.import将在webpack 2发行版(已在webpack 3中删除)中弃用,因为根据规范它的行为是不正确的。
所以我转换:
require.ensure(['./hero/homepage'], () => {
require('./hero/homepage')
}, 'hero-homepage')
Run Code Online (Sandbox Code Playgroud)
进入:
import('./hero/homepage')
.then(module => module.default)
.catch(err => console.error(`Chunk loading failed, ${err}`))
Run Code Online (Sandbox Code Playgroud)
但是得到: Module build failed: SyntaxError: 'import' and 'export' may only appear at the top level
我必须添加一些东西到webpack配置中,以允许在他们建议的地方使用导入吗?
我似乎无法找到键绑定或选择元素结束标记的能力.假设我坐在开口div标签上我想能够选择结束标签,以便能够改变这个来说一个section或者header例如.
我可以使用,Add Select for Next Occurrence但如果div元素内部有一些我想改变,那么显然它也选择了它们.
这是我试图实现的布局:
我目前正在这样做:
<div class="ft-Footer_Columns">
<div class="ft-Footer_Column ft-Footer_Column-about">
<h4 class="ft-Footer_Title">Title 1</h4>
<p class="ft-Footer_Text">Text 1</p>
</div>
<div class="ft-Footer_Column ft-Footer_Column-links">
<h4 class="ft-Footer_Title">Title 2</h4>
<p class="ft-Footer_Text">Text 2</p>
</div>
<div class="ft-Footer_Column ft-Footer_Column-contact">
<h4 class="ft-Footer_Title">Title 3</h4>
<p class="ft-Footer_Text">Text 3</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
.ft-Footer_Columns {
display: grid;
grid-column-gap: calc(20px * 2);
grid-template-columns: calc(5 / 12)fr calc(4 / 12)fr calc(3 / 12)fr;
}
Run Code Online (Sandbox Code Playgroud)
这似乎是实现我想要的东西的一种非常古怪的方式。
理想情况下,我希望能够做到:
.ft-Footer_Columns {
display: grid;
grid-column-gap: calc(20px * 2);
grid-template-columns: calc(5 / 12 * 100%) calc(4 / 12 * 100%) calc(3 / 12 …Run Code Online (Sandbox Code Playgroud)