我有一个使用 teleport to 的组件,测试 html 似乎没有按预期工作。我找不到有关此特定用途的任何文档。这是我的测试:
describe('MetaHead', () => {
it('dynamic metadata tags contain custom text', () => {
let title = 'My Page';
let description = 'Some description about my page';
// This component uses Vue3's teleport to tag <head>
// we must modify wrapper to contain such tag
document.body.innerHTML = `
<head>
<div id="app"></div>
</head>
`
const wrapper = mount(MetaHead, {
attachTo: document.getElementById('app'),
props: {
title,
description
},
global:{
mocks: {
$route:{fullPath: 'full/path'}
}
}
})
expect(wrapper.html()).toContain(title)
expect(wrapper.html()).toContain(description) …Run Code Online (Sandbox Code Playgroud) 我有一个包含以下模式的记录数组:
apis = [{
info: {
title: 'some title"
}
}]
Run Code Online (Sandbox Code Playgroud)
我需要返回用户输入是记录标题的所有记录.
我尝试使用Lodash这样的东西,但"title"总是一个字母.
this.searchResults = this.apis.filter(function(item){
return _.some(item.info.title, function (title) {
return _.includes(title, query);
});
});
Run Code Online (Sandbox Code Playgroud)