How to print a part of a vue component without losing the style

前端 未结 2 473
独厮守ぢ
独厮守ぢ 2021-02-04 14:05

I want to print some content from a vue component. For example from the following snippet, I would like to print the v-card-text element which also has an id of

2条回答
  •  执笔经年
    2021-02-04 15:05

    Install this package vue-html-to-paper

    npm install vue-html-to-paper
    

    usage:

    import Vue from 'vue';
    import VueHtmlToPaper from 'vue-html-to-paper';
    
    const options = {
      name: '_blank',
      specs: [
        'fullscreen=yes',
        'titlebar=yes',
        'scrollbars=yes'
      ],
      styles: [
        'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
        'https://unpkg.com/kidlat-css/css/kidlat.css'
      ]
    }
    
    Vue.use(VueHtmlToPaper, options);
    
    // or, using the defaults with no stylesheet
    Vue.use(VueHtmlToPaper);
    

    component: