vue 定时执行只执行一次解决办法

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qingfulang9322/article/details/82776949

  methods: {
    autoPlay () {
      this.mark++;
      if (this.mark === 4) { //当遍历到最后一张图片置零
        this.mark = 0
      }
    },
    play () {
      setInterval(this.autoPlay(), 2500)
    },
    change (i) {
      this.mark = i
    }
  },
  created () {
    this.play()

如上代码,执行的时候发现怎么都只执行一次,后来发现是setInterval中的方法加了();去掉括号即可。

展开阅读全文

为什么过滤器只执行一次

07-10

我编写了一个测试的过滤器,当我第一次装载一个servlet时,过滤器发挥作用,重复刷新该servlet时,过滤器没有被调用,是否是我的配置有问题,如果真是这样,就无法使用它来做认证了。请高手指点。谢谢rn我的web.xml:rnrn rn Servlet Mapped Filterrn filters.ExampleFilterrn rn attributern filters.ExampleFilter.SERVLET_MAPPEDrn rn rn rn rn Servlet Mapped Filterrn invokerrn rn rn rn invokerrn /servlet/*rn rnrnrnrn过滤器程序:rnpackage filters;rnimport java.io.IOException;rnimport javax.servlet.Filter;rnimport javax.servlet.FilterChain;rnimport javax.servlet.FilterConfig;rnimport javax.servlet.ServletContext;rnimport javax.servlet.ServletException;rnimport javax.servlet.ServletRequest;rnimport javax.servlet.ServletResponse;rnimport javax.servlet.http.HttpServletRequest;rnrnpublic final class ExampleFilter implements Filter rnrnrn private String attribute = null;rn private FilterConfig filterConfig = null;rn public void destroy() rn System.out.println("enter filter.destory()");rn this.attribute = null;rn this.filterConfig = null;rn rn public void doFilter(ServletRequest request, ServletResponse response,rn FilterChain chain)rn throws IOException, ServletException rn System.out.println("enter filter.doFilter()");rn // Store ourselves as a request attribute (if requested)rn if (attribute != null)rn request.setAttribute(attribute, this);rnrn // Time and log the subsequent processingrn long startTime = System.currentTimeMillis();rn chain.doFilter(request, response);rn long stopTime = System.currentTimeMillis();rn String url = ((HttpServletRequest)request).getRequestURI();rn filterConfig.getServletContext().logrn (this.toString() + "(" + url + "): " + (stopTime - startTime) +rn " milliseconds");rn rnrn public void init(FilterConfig filterConfig) throws ServletException rnrn System.out.println("enter filter.init()");rn this.filterConfig = filterConfig;rn this.attribute = filterConfig.getInitParameter("attribute");rnrn rn public String toString() rnrn if (filterConfig == null)rn return ("InvokerFilter()");rn StringBuffer sb = new StringBuffer("InvokerFilter(");rn sb.append(filterConfig);rn sb.append(")");rn return (sb.toString());rn rnrnrnrn 论坛

FOR循环只执行一次,求解?

11-21

Gridview手工增加几行,数据循环插入数据库。rn但是每次都只执行1次,插入一条记录。rn[code=csharp]rn protected void LinkButton1_Click(object sender, EventArgs e) //批量保存数据rn rn rn for (int i = 0; i < GridView1.Rows.Count; i++) //循环rn rn rn TextBox akno = (TextBox)GridView1.Rows[i].Cells[3].FindControl("kno"); //单据rn string kno = akno.Text.ToString().Trim();rn //TextBox atype1 = (TextBox)GridView1.Rows[i].Cells[4].FindControl("type1"); //大类rn //string type1 = atype1.Text.ToString().Trim();rn //TextBox atype2 = (TextBox)GridView1.Rows[1].Cells[5].FindControl("type2"); //小类rn //string type2 = atype2.Text.ToString().Trim();rn //TextBox aunit = (TextBox)GridView1.Rows[i].Cells[6].FindControl("unit"); //单位rn //string unit = aunit.Text.ToString().Trim();rn TextBox acount = (TextBox)GridView1.Rows[i].Cells[4].FindControl("count"); //入库数rn string count = acount.Text.ToString().Trim();rn TextBox aprice1 = (TextBox)GridView1.Rows[i].Cells[5].FindControl("price1"); //单价rn string price1 = aprice1.Text.ToString().Trim();rn //TextBox aprice2 = (TextBox)GridView1.Rows[i].Cells[9].FindControl("price2"); //总价rn //string price2 = aprice2.Text.ToString().Trim();rn //TextBox aoldcount = (TextBox)GridView1.Rows[i].Cells[10].FindControl("oldcount"); //原库存rn //string oldcount = aoldcount.Text.ToString().Trim();rn //TextBox anewcount = (TextBox)GridView1.Rows[i].Cells[11].FindControl("newcount"); //现库存rn //string newcount = anewcount.Text.ToString().Trim();rn TextBox aproduct = (TextBox)GridView1.Rows[i].Cells[6].FindControl("product"); //物品rn string product = aproduct.Text.ToString().Trim();rn TextBox auser = (TextBox)GridView1.Rows[i].Cells[7].FindControl("user"); //用户rn string user = auser.Text.ToString().Trim();rn TextBox ardate = (TextBox)GridView1.Rows[i].Cells[8].FindControl("rdate"); //日期rn string rdate = ardate.Text.ToString().Trim();rnrn #region 检验用户填写的物品是否存在于小类表rn SQLCMD checkproduct = db.NewCMD("select 1 from POS_stock_type2 where product=@product");rn checkproduct.Add("@product", product, DbType.String);rn if (!db.Exists(checkproduct))rn rn ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('请确保第'"+i+"'行的物品已登记,或者填写正确!!');", true);rn return;rn rn #endregionrnrn if (product=="" || count=="" || price1=="" ) //物品,入库量,单价不能为空rn rn ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('物品,入库量,单价不能为空!!');", true);rn return;rn rn elsern rnrn tryrn rn SQLCMD sb = db.NewCMD("select 1 from POS_Stock_input where kno=@kno and product=@product and rdate=@rdate"); //检查是否重复数据rn sb.Add("@kno", kno, DbType.String);rn sb.Add("@product", product, DbType.String);rn sb.Add("@rdate",rdate,DbType.String);rnrnrn if (db.Exists(sb)) //保存rn rn ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('保存数据重复,请检查!!');", true);rn return;rn rn else //保存rn rn SQLCMD up = db.NewCMD(@"insert into POS_Stock_input(kno,count,price1,product,operator,rdate) values (@kno,@count,@price1,@product,@user,@rdate)");rn up.Add("@kno", kno, DbType.String);rn //up.Add("@type1", type1, DbType.String);rn //up.Add("@type2", type2, DbType.String);rn //up.Add("@unit", unit, DbType.String);rn up.Add("@count", count, DbType.String);rn up.Add("@price1", price1, DbType.String);rn //up.Add("@price2", price2, DbType.String);rn //up.Add("@oldcount", oldcount, DbType.String);rn //up.Add("@newcount", newcount, DbType.String);rn up.Add("@product", product, DbType.String);rn up.Add("@user", user, DbType.String);rn up.Add("@rdate", rdate, DbType.String);rn db.ExecuteNonQuery(up);rn //ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('保存成功!!');", true);rnrn rn GridView1.DataBind();rn rn SQLCMD sp = db.NewCMD("exec usp_stock_input"); //调用存储过程,更新入库表表,取最新库存rn db.ExecuteNonQuery(sp);rnrn Response.Redirect("zgrk.aspx");rn rnrn rn rn catchrn rn ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('请第'"+i+"'行确保输入的数据类型正确!!');", true);rn rn rn rn rn[/code] 论坛

没有更多推荐了,返回首页