假设 vuex 状态具有如下结构:
state: {
houses: [{
pk: 1,
historicalName: 'Poo'
}],
},
Run Code Online (Sandbox Code Playgroud)
和house从所述状态的实例被用于通过将其作为道具组分(houses.vue模板):
<div><house v-for="hs in housesState" :house="hs"></house></div>
Run Code Online (Sandbox Code Playgroud)
然后当我需要改变 的字段时house,我是否像这样编写突变:
[Types.mutations.SET_HISTORICAL_NAME]: (state, payload) => {
state.houses.find(x => x.pk === payload.house.pk).historicalName = payload.historicalName
}
Run Code Online (Sandbox Code Playgroud)
还是我传递housefrom 组件的实例
this.$store.commit(Types.mutations.SET_HISTORICAL_NAME, {house: this.house, historicalName: 'Gold'})
Run Code Online (Sandbox Code Playgroud)
并在不搜索数组的情况下更新它?
[Types.mutations.SET_HISTORICAL_NAME]: (state, payload) => {
payload.house.historicalName = payload.historicalName
}
Run Code Online (Sandbox Code Playgroud)
第二个选项会导致状态锁定吗?可以同时为不同的houses. 会更快吗?不每次都搜索数组应该会有所帮助,但我不确定这里是否那么简单。
房屋数据也被其他组件使用(我在问题中简化了数据结构),所以我认为我不能只存储house在本地组件级别。
从 4.9.0 版本开始,BeautifulSoup4 改变了 [0] textprop 的工作方式,现在忽略嵌入脚本的内容:
= 4.9.0 (20200405)
...
* Embedded CSS and Javascript is now stored in distinct Stylesheet and
Script tags, which are ignored by methods like get_text() since most
people don't consider this sort of content to be 'text'. This
feature is not supported by the html5lib treebuilder. [bug=1868861]
Run Code Online (Sandbox Code Playgroud)
因此,现在不再可能使用wanted text.html提取html 。<script>wanted text</script>soup.find('script').text
现在提取它的首选方法是什么?我宁愿选择不删除<script>,并</script>从str(script)手工制作。
[0] - https://bazaar.launchpad.net/~leonardr/beautifulsoup/bs4/view/head:/CHANGELOG