res

小程序获取元素高度

…衆ロ難τιáo~ 提交于 2020-01-23 02:39:57
针对有定位元素 var query = wx.createSelectorQuery(); var scrollLeft = that.data.scrollLeft query.select(’.stitTop’).boundingClientRect() query.select(’.time’).boundingClientRect() query.select(’.info’).boundingClientRect() var myTime = setTimeout(function () { query.exec((res) => { console.log(res[0].height) console.log(res[1].height) console.log(res[2].height) var shopListHeight = wx.getSystemInfoSync().windowHeight - (res[0].height + 15) - res[1].height - 54 var shopAdsTrue = shopListHeight - 110 console.log(shopListHeight) that.setData({ scrollLeft: shopListHeight, scrolllist: shopAdsTrue, }) })

vue项目登陆页记住密码功能以及菜单权限

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-22 02:01:17
< template > < div class = "login_bg" > < div class = "login_wrap" > < div class = "el-login" > < div class = "title" > { { loginTitle } } < /div > < ! --登录表单-- > < el-form ref = "formRef" class = "form_wrap" :rules = "formRules" :model = "formInfo" > < el-form-item style = "margin-bottom: 40px;" prop = "phone" > < el-input class = "inputStyle" v-model = "formInfo.phone" placeholder = "请输入用户名/账号" > < /el-input > < /el-form-item > < el-form-item prop = "password" > < el-input type = "password" autocomplete = "off" class = "inputStyle" v-model = "formInfo.password" placeholder = "请输入密码" show

Ant Design Vue 表单验证踩坑

自古美人都是妖i 提交于 2020-01-20 04:36:36
最近一个项目用了 Ant Design Vue ,我也不知道为啥用这个。。。FORM表单验证踩地坑简直是让我哭哭哭 以前用elementUI,Iview,很顺手,v-model简直是标配 可是这个Ant Design Vue 在需要验证的时候 不能用 v-model ,用 v-decoration 。 贴代码 如下 <style lang="less"> @import 'sourceManage'; </style> <template> <div ref="sourceManage"> <a-row :gutter="24"> <a-col :sm="12" :md="8" :xl="8"> <h3> 所属类目: <span>{{databaseType}}</span> </h3> </a-col> <a-col :sm="12" :md="3" :xl="3" :offset="11"> <a-button type="primary" icon="plus" @click="showSourseForm">添加源</a-button> </a-col> </a-row> <a-row :gutter="24" style="margin-top:30px;" v-if="databaseInformation.length"> <a-col :sm="12" :md="8

导出表格操作

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-16 15:50:47
// 导出参与人名单 exportPlayerInfo () { let form = { activityId: this.activityId } API.exportPlayerInfo(form).then(res => { if (+res.status === 200) { if (+res.data.code === -1) { this.sentMsg(res.data.message) return } let elink = document.createElement('a') elink.download = this.table.title + '.xls' elink.style.display = 'none' let blob = new Blob([res.body]) elink.href = window.URL.createObjectURL(blob) document.body.appendChild(elink) elink.click() document.body.removeChild(elink) } else { this.sentMsg(res.data.message || '下载失败') } }, res => { this.sentMsg() }) }, 来源: https://www.cnblogs.com

leetcode【高级】二 叉树中的最大路径和 java

ぐ巨炮叔叔 提交于 2020-01-16 15:40:32
题干 给定一个非空二叉树,返回其最大路径和。 本题中,路径被定义为一条从树中任意节点出发,达到任意节点的序列。该路径至少包含一个节点,且不一定经过根节点。 示例 1: 输入 : [ 1 , 2 , 3 ] 1 / \ 2 3 输出 : 6 示例 2: 输入 : [ - 10 , 9 , 20 , null , null , 15 , 7 ] - 10 / \ 9 20 / \ 15 7 输出 : 42 想法 首先要注意的是 【路径】是不能重复同一个节点很多次的 因为路径是一个序列他不能重复 其次因为是二叉树 天然想到递归 对每一个节点而言 如果它的路径的和大于0 那么就要它的路径的全部 如果是根节点 那么所有和大于0的左右路径都加入 如果不是根节点 那么将左右路径的大的那个加入即可 好直接看代码应该看得懂哈 直接动态规划+递归就能解决 Java代码 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ class Solution { int res = Integer . MIN_VALUE ; //初始化 public int

leetcode 132 分割回文串 II

こ雲淡風輕ζ 提交于 2020-01-15 09:58:14
给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串。 返回符合要求的最少分割次数。 示例: 输入: "aab" 输出: 1 解释: 进行一次分割就可将 s 分割成 ["aa","b"] 这样两个回文子串。 使用dfs完败,字符串中如果回文串少且长度够长,直接超时JJ。 1 public class _132 { 2 3 /** 4 * @param t 回文串的长度 5 * @param res 最少的分割次数 6 * @param depth 当前递归的层数 7 * @param cur 当前所在的字符位置 8 * @return 最小的分割次数 9 */ 10 public int dfs(int[][] t , int res, int depth, int cur) { 11 if (res < depth || cur == -1) return res; 12 13 for (int i = t[cur][0]; i > 0; --i){ 14 if (cur - t[cur][i] == -1) { 15 res = Math.min(res, depth); 16 } 17 res = Math.min(dfs(t, res, depth+1, cur-t[cur][i]), res); 18 } 19 return res; 20 } 21 22

视图函数中的序列化

本小妞迷上赌 提交于 2020-01-15 00:40:42
方式一 from django.core import serializers # 导入模块 res = serializers.serialize('json', hosts_list) return HttpResponse(res) 方式二 res = hosts_list.values('hostname', 'ip') import json res = json.dumps(list(res)) # 注意加上list函数 return HttpResponse(res) 但这种方法不能序列化如时间等数据 方式三 自定义序列化 from datetime import datetime from datetime import date import json # Create your tests here. class CustomEncoder(json.JSONEncoder): # 重写自定义序列化的方法 def default(self, field): if isinstance(field, datetime): return field.strftime('%Y-%m-%d %H:%M:%S') elif isinstance(field, date): return field.strftime('%Y-%m-%d') else: return

装饰器

只愿长相守 提交于 2020-01-14 02:01:19
装饰器 把一个函数当作参数传递给另一个函数 返回一个替代版的函数 本质上就是一个返回函数的函数 在不改变原函数的基础上 给函数增加功能 def add_one ( number ) : return number + 1 a = add_one ( 2 ) print ( a ) 函数可以作为参数被传递 # def say_hello(name): # return f"Hello {name}" # def be_some(name): # return f"Your {name}" # # def greet_bob(func): # return func("Bob") # # print(greet_bob(say_hello)) # print(greet_bob(be_some)) # def say(): # # print('*********') # print('hello') # def hello(): # print('!!!!!!!!!!!!!!hello') def fun ( f ) : def inner ( ) : print ( '*********' ) f ( ) print ( '############' ) return inner @fun #语法糖 def hello ( ) : print ( '!!!!!!!!!!!!!

QQ小程序广告代码

孤街浪徒 提交于 2020-01-13 05:02:42
qml内代码: < view bindtap = " SeeAds " > 点击查看广告 </ view > js代码如下: SeeAds ( ) { qq . showModal ( { title : '亲!需看一段小广告才能同步哦' , success : ( res ) => { if ( res . confirm ) { let videoAd = qq . createRewardedVideoAd ( { adUnitId : '75dadce5c02752a68b7f31900c4f126b' } ) videoAd . onError ( function ( res ) { console . log ( '监听广告错误 请检查网络' , res ) } ) videoAd . onLoad ( function ( res ) { console . log ( '监听广告加载' , res ) } ) videoAd . onClose ( res => { if ( res . isEnded ) { qq . setStorageSync ( 'nodesdata' , this . data . datalist ) qq . showToast ( { title : '同步成功!' , duration : 2000 } ) } else {

用JS制作一个简易GPA计算器

妖精的绣舞 提交于 2020-01-10 10:56:41
这是我第一次使用JS,有问题的地方还希望大佬指出 程序的容错性还没做到完美,日后补充 <!DOCTYPE html> < html > < head > < meta charset = " utf-8 " > < title > GPA计算工具 </ title > < script > function getNum ( ) { document . getElementById ( "in" ) . innerHTML = "" ; var cnum = Number ( document . getElementById ( "cNum" ) . value ) ; var content ; for ( i = 0 ; i < cnum ; i ++ ) { content = document . getElementById ( "res" ) . innerHTML ; document . getElementById ( "in" ) . innerHTML = content + "<br>第" + ( i + 1 ) + "门成绩: <input id=\"sc" + i + "\" type=\"number\"> 学分:<input id=\"cr" + i + "\" type=\"number\">" ; } content = document .