11# 挂载选项
22
3- 即 ` mount ` 和 ` shallow ` 的选项。该对象同时包含了 Vue Test Utils 挂载选项和其它选项。
3+ 即 ` mount ` 和 ` shallowMount ` 的选项。该对象同时包含了 Vue Test Utils 挂载选项和其它选项。
44
55- [ ` context ` ] ( #context )
66- [ ` slots ` ] ( #slots )
@@ -48,7 +48,7 @@ expect(wrapper.is(Component)).toBe(true)
4848import Foo from ' ./Foo.vue'
4949import Bar from ' ./Bar.vue'
5050
51- const wrapper = shallow (Component, {
51+ const wrapper = shallowMount (Component, {
5252 slots: {
5353 default: [Foo, Bar],
5454 fooBar: Foo, // 将会匹配 `<slot name="FooBar" />`。
@@ -86,7 +86,7 @@ There are three limitations.
8686示例:
8787
8888``` js
89- const wrapper = shallow (Component, {
89+ const wrapper = shallowMount (Component, {
9090 scopedSlots: {
9191 foo: ' <p slot-scope="props">{{props.index}},{{props.text}}</p>'
9292 }
@@ -98,7 +98,7 @@ expect(wrapper.find('#fooWrapper').html()).toBe('<div id="fooWrapper"><p>0,text1
9898
9999- 类型:` { [name: string]: Component | boolean } | Array<string> `
100100
101- 将子组件存根。可以是一个要存根的组件名的数组或对象。如果 ` stubs ` 是一个数组,则每个存根都是一个 ` <!---- > ` 。
101+ 将子组件存根。可以是一个要存根的组件名的数组或对象。如果 ` stubs ` 是一个数组,则每个存根都是一个 ` <${component name}-stub > ` 。
102102
103103示例:
104104
@@ -109,7 +109,7 @@ mount(Component, {
109109 stubs: [' registered-component' ]
110110})
111111
112- shallow (Component, {
112+ shallowMount (Component, {
113113 stubs: {
114114 // 使用一个特定的实现作为存根
115115 ' registered-component' : Foo,
@@ -129,7 +129,7 @@ shallow(Component, {
129129
130130``` js
131131const $route = { path: ' http://www.example-path.com' }
132- const wrapper = shallow (Component, {
132+ const wrapper = shallowMount (Component, {
133133 mocks: {
134134 $route
135135 }
@@ -198,14 +198,12 @@ expect(wrapper.vm.$route).toBeInstanceOf(Object)
198198- 类型:` boolean `
199199- 默认值:` true `
200200
201- 将所有的侦听器都设置为同步执行。
202-
203201当 ` sync ` 是 ` true ` 时,这个 Vue 组件会被同步渲染。
204202当 ` sync ` 是 ` false ` 时,这个 Vue 组件会被异步渲染。
205203
206204## 其它选项
207205
208- 当 ` mount ` 和 ` shallow ` 的选项包含了挂载选项之外的选项时,则会将它们通过[ 扩展] ( https://vuejs.org/v2/api/#extends ) 覆写到其组件选项。
206+ 当 ` mount ` 和 ` shallowMount ` 的选项包含了挂载选项之外的选项时,则会将它们通过[ 扩展] ( https://vuejs.org/v2/api/#extends ) 覆写到其组件选项。
209207
210208``` js
211209const Component = {
0 commit comments