如何在vuejs中的页面加载时触发方法?

时间:2016-01-28 14:59:00

标签: javascript jquery vue.js

如何在标签页面加载时触发方法?
例如:

<div id='wraper'>
<!-- div id menu not load -->
<div id="menu">
  <a href='#'>test</a>
  <a href='#'>test</a>
  <a href='#'>test</a>
</div>

<!-- load this content  -->
<div id="content">
konten
</div>
  
</div>  

由于

2 个答案:

答案 0 :(得分:42)

对于vue&gt; = 2.0 使用ready和以前的版本使用vm=new Vue({ el:"#app", mounted:function(){ this.method1() //method1 will execute at pageload }, methods:{ method1:function(){ /* your logic */ } }, })

Rectangle pageSize = PageSize.A1;
Document doc = new Document(pageSize.Rotate(), 10f, 10f, 10f, 10f);

PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(@"C:\TestFiles\Default.pdf", FileMode.Create));
doc.Open();

Image image = Image.GetInstance(@"C:\TestFiles\image.png");

PdfPTable table = new PdfPTable(1);
table.WidthPercentage = 100;
PdfPCell c = new PdfPCell(image, true);
c.Border = PdfPCell.NO_BORDER;
c.Padding = 5;
c.Image.ScaleAbsoluteHeight(pageSize.Height);
table.AddCell(c);
doc.Add(table);

doc.Close();

答案 1 :(得分:4)

这种语法运行正常:

export default {
    mounted() {
      this.mymethod()
    },
}