报错:[Vue warn]: Property or method "getViewExtend" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
代码如下:
<template>
<div>
<el-dialog
class="multiPeriodImagesDialog"
title="历史数据"
:visible.sync="showdialog"
:close-on-click-modal="choosefalse"
width="20%"
top="13vh"
:modal="choosefalse"
@opened="getViewExtend"
v-el-drag-dialog
>
<light-timeline :items="items" class="lightTimeline">
<template slot="tag" slot-scope="{ item }">
{{ item.date }}
</template>
<template slot="content" slot-scope="{ item }">
{{ item.msg }}
</template>
</light-timeline>
</el-dialog>
</div>
</template>
<script>
import elDragDialog from "@/components/commonUI/el-drag-dialog";
export default {
name: "MultiPeriodImages",
directives: { elDragDialog },
data() {
return {
showdialog: false,
choosefalse: false,
items: [
{
date: "2019-02-12",
msg: "测试内容",
},
{
date: "2019-02-13",
msg: "练习内容",
},
{
date: "2019-02-13",
msg: "练习内容",
},
{
date: "2019-02-13",
msg: "练习内容",
},
{
date: "2019-02-13",
msg: "练习内容",
},
{
date: "2019-02-13",
msg: "练习内容",
},
],
};
},
initHistoryData() {
getViewExtend();
},
getViewExtend() {},
};
</script>
原来是忘了把函数initHistoryData()和getViewExtend()放到methods:{}中。