methods: {
pdf:function(){
var _html;
this.$nextTick(()=>{
var html=document.querySelector('.Content');
var _html=html
console.log(_html) //第一个
});
console.log(_html) //第二个
}
}
用VUE获取渲染后的HTML代码,
this.$nextTick里的console.log(_html)(第一个)可以获取到html代码
但在pdf:function()里的console.log(_html)(第二个)为undefined
如何把渲染后的HTML代码可以赋值到this.$nextTick()的外面去?
=========================================
补充内容:
pdf:function(){
var name="合同";
var _html=document.querySelector('.Content');
//document.querySelector('.Content')好像这样获取的也是渲染后的html
$.ajax({
type: "POST",
dataType: "json",
url: "{:url('api/pdf/create')}",
data: { 'html': _html,'name':name},
success:function(res){
//把_html进行ajax提交提示如下:
//TypeError: Cannot set property 'cache' of undefined
}
});
}