我在不同项目中使用describe Tag do
context 'retrieving all tags' do
let(:tag) { Tag.create! }
before do
allow(Tag).to receive(:all_uncached) do
fail 'Database hit!' if @database_hit
@database_hit = true
[tag]
end
end
context 'when the cache is populated' do
before { Tag.all_cached }
it 'should not hit the database' do
expect(Tag.all_uncached).to raise_error 'Database hit!'
expect(Tag.all_cached).to eq [tag]
end
end
end
end
和React.js
作为前端。
在React中,我可以像这样用Vue.js
包装模板。
MyComponent
在MyComponent文件中
<MyComponent>
<div>Here</div>
</MyComponent>
如何在const MyComponent = ({children}) {
return (
<div className="my-component">{children}</div>
)
}
中使用这种简单的技术?
答案 0 :(得分:2)
您将要使用Slots。
以下是摘自vuejs文档的示例
组件模板:
<a :href="url">
<slot></slot>
</a>
代码:
<navigation-link url="/profile">
Your Profile
</navigation-link>
<slot></slot>
将替换为组件标签中的内容。它将呈现为:
<a url="/profile">
Your Profile
</a>