随笔

  1. vue项目中,window.onresize监听屏幕大小事件只能挂载一次。多次挂载只有一个生效。应避免。
    可使用
mouted(){
 	window.addEventListener("resize", this.resizeCanvas);
},
beforeDestroy() {
    window.removeEventListener("resize", this.resizeCanvas);
}
  1. vue目前没有找到方便的支持对象拖拽、移动等等功能的canvas画图框架, konvas.js有中文版的使用文档没有中文版,目前我是用原生canvas写的。
  2. php跳转:
{:url('faq/getAllQuestionCategories',['choice' =>'1'])}
{:url('faq/getAllQuestionCategories')}
url('editschool',['id'=>$question_id])
function goBack(){
    window.location.href="{:url('/front/faq/answer?id="+question_id+"')}";
}

$this->redirect(url('login/index'));

php树遍历:

public function getTree($hid){
    $ret=db("question_category")->where("pid",$hid)->select();
    if(0 &$value) {
            $list=$this->getTree($value['id']);
            if(0
public function deleteCategoryTree($hid){
    $ret=db("question_category")->where("id",$hid)->delete();
    $ret=db("question_category")->where("pid",$hid)->select();
    if(0 $value) {
            $list=$this->deleteCategoryTree($value['id']);
        }
    }
    return $ret;
}

4.指定属性查找对象数组中匹配的项,使用过滤器:

var data= datas.filter(function(item){
     return item.bianma == "12"; 
})
  1. 今天被 window.JSON.stringify() 和 JSON.stringify()搞蒙了,大家在 JSON.stringify()报is not a function时可以尝试以下 window.JSON.stringify()。

  2. 切换页面时定时器的处理方法

if (self && !self._isDestroyed) {
  this.dispatch = setTimeout(() => {
    self.fetchShopNotOrderingList()
  }, 10000)
}
  1. 三元运算符进行判断时,如何条件是为undefined时会报错而不会当成false处理。

  2. 画布canvas拖拽对象的基本思路是保存现场、作出改动、还原改动的现场。

你可能感兴趣的:(前端开发)