vue 中如何获取 slot 中的内容

2020-03-03 09:49:29

有时候我们需要获取slot中的内容,这样我们能做一些逻辑类的东西

<template>
  <div>
    <slot></slot>
  </div>
</template>
<script>
export default {
	//怎么获取 slot 中的内容呢?
}
</script>


我们可以使用  this.$slots.default


当然这是默认的,我们只要把default改成我们想要的slot名称,console下this.$slot.default试试吧。

  • 2017-11-06 01:00:17

    撤销git add

    如何撤销git add,不小心执行了git add . 操作,但是又不能提交所有的文件,因为对应不同的分支,现在怎么样可以将git add 撤销回来

  • 2017-11-10 00:06:15

    CORS: credentials mode is 'include'

    XMLHttpRequest cannot load http://localhost/Foo.API/token. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:5000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.