Vue extends page template

problem description

use vue"s extends,mixins to make page templates.
how can I inherit template, or have a better template?

the environmental background of the problems and what methods you have tried

is using vue (vue-cli) to create a web page app with a large number of subpages. These subpages usually come in several fixed forms, such as the details on the right side of the list on the left, with four add / delete / cancel / confirm buttons. Therefore, it is very useful to make some general-purpose templates.
then came the idea of using extends to create and inherit templates: in
extends, options such as data/methods are easy to understand and use.
is mainly the content of template. The test found that template will be covered, and the inheritor must be fully compatible with the template content of the inherited component to achieve the effect. Or if the inheritor"s template is empty, the inherited component"s template, is used, but it doesn"t work.

related codes

// App.vue
...
<script>
import ExtendsSample from "./components/ExtendsSample.vue"
export default {
  name: "App",
  extends: ExtendsSample,
  data () {
...

what result do you expect? What is the error message actually seen?

hope to find a template with partial template inheritance

Jul.07,2021

using parent-child nested components


I also encountered such a demand. After studying the vue source code for a long time, I found a solution ~
subcomponents that can be used in this way

    render(h) {
        var superRendered = this.$options.extends.render.apply(this, arguments)
        if (this.uiSet) {
            var button = <el-button></el-button>
        }
        return <div>{superRendered}{button}</div>
    }

superRendered is the result of the parent component template rendering! this.$options.extends.render.apply (this, arguments) this sentence is the key.

Menu