![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
微信小程序开发框架。实现单文件开发模式,支持ES7以上语法和集成GraphQL工具包
(目前属于实验阶段,仅支持pug模版引擎、javascript和sass/scss样式语言)
npm i @sureking/mp --save-dev
项目入口文件引入@sureking/mp进行小程序项目构建
require('@sureking/mp')({
src: 'src', // 小程序源代码目录,默认 src
dist: 'weapp', // 小程序编译后输出目录,默认 weapp
appid: 'appid', // 小程序appid -必填
projectName: 'mp' // 小程序项目名称 -必填
devDefine: { // 定义开发模式下的编译变量
BASE_URL: 'http://localhost:1025' // 使用内置网络工具(上传工具、微信接口工具、Graphql工具)和当前为serve模式时必填
},
prodDefine: { // 定义生产模式下的编译变量
BASE_URL: 'https://api.sureking.cn' // 使用内置网络工具(上传工具、微信接口工具、Graphql 工具)和当前为 build 模式时必填
}
})
使用编译变量
define.BASE_URL //根据模式自动使用devDefine或prodDefine中定义的变量值
模版文件采用mp后缀,其他后缀均不能被模版解析器识别,如: home.mp
mp文件是小程序开发时的最重要文件,分别定义视图、配置、脚本、样式
<template lang="pug">
.container 这是一个测试页面
</template>
<config>
{
usingComponents: {
navigation: '../components/navigation'
}
}
</config>
<script>
import api from './api'
Page({
data:{
text: ''
},
onLoad(){
this.setData({
text: 'foo'
})
}
})
</script>
<style lang="sass">
@import './color'
page
font-size: 16px
.container
height: 100%
display: flex
flex-direction: column
align-items: center
justify-content: space-between
box-sizing: border-box
</style>
方法
Format(fmt:String):String
参数
返回值:格式化后的 String
new Date().Format('yyyy-MM-dd hh:mm:ss.SSS q')
方法
Calc(year:Number,month:Number,day:Number):Date
参数
返回值:Date 计算后的日期
new Date().Calc(1,2,3) // 计算未来1年零2个月3天
new Date().Calc(0,0,-3) // 计算过去3天
方法
Date(year?:Number,month?:Number,day?:Number):String
参数
返回值:String 计算后经格式化的日期
new Date().Date(1,0,0) // 返回一年后的今天,按yyyy-MM-dd格式输出
方法
DateTime(year?:Number,month?:Number,day?:Number):String
参数
返回值:String 计算后经格式化的日期时间
new Date().DateTime(1,0,0) // 返回一年后的今天,按yyyy-MM-dd hh:mm:ss格式输出
方法
Time():String
参数:无
返回值:String 经格式化的时间
new Date().Time() // 返回当前时间,按hh:mm:ss格式输出
方法
MonthDiff(reference:String):Number
参数
返回值: Number 相隔月数
// 计算2020年1月10日距离今天有多少月
new Date('2020-01-10').MonthDiff()
// 计算2020年1月10日距离2020年5月30日有多少月
new Date('2020-01-10').MonthDiff('2020-05-30')
方法
prefix(digit:Number):String
参数
返回值:String 补零后的字符串
'1'.prefix(5) // 返回00001
方法
graphql(args:Object):Promise<Any>
参数
返回值:Promise<Any> graphql 服务器响应的对象
const query = `query@users.list>>UserInput->data{page size length data{name age mobile gender area}}`
query.graphql({page:1,size:10}).then(user=>{
// user
})
方法
wechat(data:Object, method:String):Promise<Any>
参数
返回值:Promise<Any> 服务器响应的对象
'orders.pay'.wechat({
order_no: 'xxxxxxxx',
openid: 'xxxxxxxxxxxxxx',
total_fee: 3000
},'POST').then(res=>{
....
})
方法
file():String
参数:无
返回值:String,服务器文件地址
'xxxxxxxxxx'.file()
方法
rich():String
参数:无
返回值:String,转义后的富文本,可在rich-text组件显示
'xxxxxxxxxx'.rich()
方法
global(object:Any):void
global():Any
参数
返回值:void | Any, 设置全局变量操作时没有返回值,获取全局变量操作时返回该变量的值
'userInfo'.global({name:'张三'})
console.info('userInfo'.global()) // 输出: {name:'张三'}
方法
thou():String
参数:无
返回值:String,格式化后的字符串
console.info(1000.thou()) // 输出:1,000.00
方法
GroupBy(c:Function):Object
参数
返回值:Object 分组对象
const goods = [
{category:'A',name:'商品 1'},
{category:'A',name:'商品 2'},
{category:'A',name:'商品 3'},
{category:'B',name:'商品 4'},
{category:'B',name:'商品 5'},
{category:'B',name:'商品 6'}
]
const group = goods.GroupBy(item=>item.category)
/**
group的值为
{
A: [
{category:'A',name:'商品 1'},
{category:'A',name:'商品 2'},
{category:'A',name:'商品 3'}
]
B: [
{category:'B',name:'商品 4'},
{category:'B',name:'商品 5'},
{category:'B',name:'商品 6'}
]
}
*/
FAQs
微信小程序开发框架。实现单文件开发模式,支持ES7以上语法和集成GraphQL工具包
We found that @kway/mp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.