反正你们写的都是没有即时演示的教程,我为什么不去看官方文档?


我就拿Vue举个栗子。

Vue.js是什么,我想你多半知道,不然你也不会打开这篇文章。

这几天看到写Vue教程的文章突然多起来了。不过,就我所见,在这里发表的所有教程文章,都不支持即时演示,顶多有点儿自己画的图片之类的点缀一下。那么,请问您的文章和官网的交互式教程相比有什么优势?高级技巧或者独创的tricks就算了,那些写基础教程的作者们,您的目标读者全是不看官方文档,吃不下饼干非得您给嚼碎了再喂的那种蠢驴吗?

但是!

看完这篇文章,你至少可以在你的教程里加入一些简单的Vue交互(或者别的骚东西)!就像这个被我搬过来的官方例子一样:

《进入/离开 & 列表过渡:列表的排序过渡》

Add
Remove

{{ item }}

▲ 点一下按钮

new Vue({
el: ‘#list-complete-demo‘,
data: {
items: [1,2,3,4,5,6,7,8,9],
nextNum: 10
},
methods: {
randomIndex: function () {
return Math.floor(Math.random() * this.items.length)
},
add: function () {
this.items.splice(this.randomIndex(), 0, this.nextNum++)
},
remove: function () {
this.items.splice(this.randomIndex(), 1)
}
}
})

.list-complete-item {
transition: all 1s;
display: inline-block;
margin-right: 10px;
}
.list-complete-enter, .list-complete-leave-to
/* .list-complete-leave-active for below version 2.1.8 */ {
opacity: 0;
transform: translateY(30px);
}
.list-complete-leave-active {
position: absolute;
}

几个关键

给文章加上interactive内容,尤其是在第三方平台(比如BKY)发表的文章,没有插件功能,必须用到HTML权限。但是文章内的<script>已经被屏蔽了,直接写是不会解析的。所以为了让文章能交互,你得绕过script的屏蔽。

简易代码执行器

我在《如何绕过BKY对 script 的屏蔽》里提供了一个简易的解决方案,我称为简易代码执行器(ECE)。就目前的效果而言,正如你在这篇文章里看到的,它的效果还挺好的,至少够用了。通过每篇文章各自执行代码,你可以省去在全局设置里不断添加新代码的烦恼。相信我,当你写的文章越来越多,global maintenance会把你逼疯的。等到哪天不用这些代码了,直接删除文章就好,免去了在狭小的设置对话框的犄角旮旯里寻找作废代码的烦恼。

ECE会读取文章里所有可识别的代码块,然后分别执行它们。对我这个博客来说,一个标准的文章内嵌代码块是用 run 或者 runearly 标签包围的代码块:

<run>
    <!-- some code -->
</run>

文章加载完毕后,ECE就会开始逐个执行代码块里的some code。拿一个简单的Vue官方代码举例:

《介绍:处理用户输入》

{{ message }}

逆转消息

var app5 = new Vue({
el: ‘#app-5‘,
data: {
message: ‘Hello Vue.js!‘
},
methods: {
reverseMessage: function () {
this.message = this.message.split(‘‘).reverse().join(‘‘)
}
}
})

普通的博客文章(就是我吐槽的那些基础教程)是没法做到上面这样真正使用Vue.js实现的交互效果的。如果不用别的招,它们只能在文章里干瘪地罗列出一堆代码,读者看了半天也是满头雾水,依然不知道这玩意儿到底是个什么样。有心的读者也许会按图索骥,摸到官网去看文档和交互演示,心中满是问号:为什么不从一开始就直接看官网。而意志薄弱的哥们儿,可能就此放弃阅读,关掉网页,顺便再骂上一句:辣鸡文章。

如果用了内嵌代码块这种methodology,只需要在文章正文写上HTML代码:

<div id="app-5">
    <p>{{ message }}</p>
    <button v-on:click="reverseMessage">逆转消息</button>
</div>

然后把Vue语句写到一个run标签里

<run>
var app5 = new Vue({
    el: '#app-5',
    data: {
        message: 'Hello Vue.js!'
    },
    methods: {
        reverseMessage: function() {
            this.message = this.message.split('').reverse().join('')
        }
    }
})
</run>

文章正文内容加载完后,ECE会执行这些Vue代码,就能得到上面的交互效果。

简易代码执行器的实现很简单,它分为标准执行阶段推迟执行阶段。由 runearly 包裹的代码块在DOM加载完毕后就开始执行,相当于:

$(function() {
    /* 代码 */
});

run里的代码需要等到文档全部载入后才执行,相当于:

$(window).load(function() {
    /* 代码 */
});

这很好理解,如果想不明白,看看我前面提到的那篇文章。

多个代码块之间传递变量

我的代码是用eval执行的,这带来一个问题:多个run代码块之间没法直接传递变量。比如我写:

<run>
    var a = 1;
</run>
<run>
    a = a + 1;
</run>

第二个run是没法执行的,浏览器会报错:

ReferenceError: a is not defined

a的生命周期只限于第一个run内。为了解决这个问题,我在全局设置里增加了一个缓存变量和三个助手函数,分别用来读取/写入/删除需要共享的变量:

var steady = new Array();

function getValue(name) {
    return steady[name];
}

function setValue(name, value) {
    steady[name] = value;
}

function removeValue(name) {
    steady.remove(name);
}

steady因为是写在全局设置里的,它的生命周期是整个session。通过它,各个代码块之间就可以传递变量了,这样,你在写文章尤其是长文章时就能把代码块分开写在文章不同的位置,而不用把所有的代码都挤在一个run里,影响写作思路。

另外一种变量传递解决方案是使用cookie完成。Cookie优点在于可以在不同页面间传递值,这一点上面的方案是办不到的。但是它的缺点也和优点一样明显。Cookie没办法直接保存除了字符串和数字之外的变量,比如数组。好在大部分网页内容和变量都可以通过序列化转换成JSON字符串进行保存/读取。Cookie的操作可以借用js-cookie完成,非常方便。

其他的骚操作

有了运行代码块的能力,你可以在讲解Vue的时候,引入其他的内容配合讲解。比如把Vue和ECharts结合起来,实现图文并茂的讲解和阐述。轻轻松松就可以画出精美的交互式图表,再搭配Vue的动态绑定插槽等等。这样装修之后文章自然完爆那些用着默认主题,呆板、无神的鸡肋文。下面这两张图都是可以点的,试试看:


Loading...

▲ 数据演示

function paintCanvas(canvas) {
var myChart = echarts.init(document.getElementById(canvas));
myChart.showLoading();
var json_data = {
"name": "flare",
"children": [{
"name": "analytics",
"children": [{
"name": "cluster",
"children": [{
"name": "AgglomerativeCluster",
"value": 3938
}, {
"name": "CommunityStructure",
"value": 3812
}, {
"name": "HierarchicalCluster",
"value": 6714
}, {
"name": "MergeEdge",
"value": 743
}]
}, {
"name": "graph",
"children": [{
"name": "BetweennessCentrality",
"value": 3534
}, {
"name": "LinkDistance",
"value": 5731
}, {
"name": "MaxFlowMinCut",
"value": 7840
}, {
"name": "ShortestPaths",
"value": 5914
}, {
"name": "SpanningTree",
"value": 3416
}]
}, {
"name": "optimization",
"children": [{
"name": "AspectRatioBanker",
"value": 7074
}]
}]
}, {
"name": "animate",
"children": [{
"name": "Easing",
"value": 17010
}, {
"name": "FunctionSequence",
"value": 5842
}, {
"name": "interpolate",
"children": [{
"name": "ArrayInterpolator",
"value": 1983
}, {
"name": "ColorInterpolator",
"value": 2047
}, {
"name": "DateInterpolator",
"value": 1375
}, {
"name": "Interpolator",
"value": 8746
}, {
"name": "MatrixInterpolator",
"value": 2202
}, {
"name": "NumberInterpolator",
"value": 1382
}, {
"name": "ObjectInterpolator",
"value": 1629
}, {
"name": "PointInterpolator",
"value": 1675
}, {
"name": "RectangleInterpolator",
"value": 2042
}]
}, {
"name": "ISchedulable",
"value": 1041
}, {
"name": "Parallel",
"value": 5176
}, {
"name": "Pause",
"value": 449
}, {
"name": "Scheduler",
"value": 5593
}, {
"name": "Sequence",
"value": 5534
}, {
"name": "Transition",
"value": 9201
}, {
"name": "Transitioner",
"value": 19975
}, {
"name": "TransitionEvent",
"value": 1116
}, {
"name": "Tween",
"value": 6006
}]
}, {
"name": "data",
"children": [{
"name": "converters",
"children": [{
"name": "Converters",
"value": 721
}, {
"name": "DelimitedTextConverter",
"value": 4294
}, {
"name": "GraphMLConverter",
"value": 9800
}, {
"name": "IDataConverter",
"value": 1314
}, {
"name": "JSONConverter",
"value": 2220
}]
}, {
"name": "DataField",
"value": 1759
}, {
"name": "DataSchema",
"value": 2165
}, {
"name": "DataSet",
"value": 586
}, {
"name": "DataSource",
"value": 3331
}, {
"name": "DataTable",
"value": 772
}, {
"name": "DataUtil",
"value": 3322
}]
}, {
"name": "display",
"children": [{
"name": "DirtySprite",
"value": 8833
}, {
"name": "LineSprite",
"value": 1732
}, {
"name": "RectSprite",
"value": 3623
}, {
"name": "TextSprite",
"value": 10066
}]
}, {
"name": "flex",
"children": [{
"name": "FlareVis",
"value": 4116
}]
}, {
"name": "physics",
"children": [{
"name": "DragForce",
"value": 1082
}, {
"name": "GravityForce",
"value": 1336
}, {
"name": "IForce",
"value": 319
}, {
"name": "NBodyForce",
"value": 10498
}, {
"name": "Particle",
"value": 2822
}, {
"name": "Simulation",
"value": 9983
}, {
"name": "Spring",
"value": 2213
}, {
"name": "SpringForce",
"value": 1681
}]
}, {
"name": "query",
"children": [{
"name": "AggregateExpression",
"value": 1616
}, {
"name": "And",
"value": 1027
}, {
"name": "Arithmetic",
"value": 3891
}, {
"name": "Average",
"value": 891
}, {
"name": "BinaryExpression",
"value": 2893
}, {
"name": "Comparison",
"value": 5103
}, {
"name": "CompositeExpression",
"value": 3677
}, {
"name": "Count",
"value": 781
}, {
"name": "DateUtil",
"value": 4141
}, {
"name": "Distinct",
"value": 933
}, {
"name": "Expression",
"value": 5130
}, {
"name": "ExpressionIterator",
"value": 3617
}, {
"name": "Fn",
"value": 3240
}, {
"name": "If",
"value": 2732
}, {
"name": "IsA",
"value": 2039
}, {
"name": "Literal",
"value": 1214
}, {
"name": "Match",
"value": 3748
}, {
"name": "Maximum",
"value": 843
}, {
"name": "methods",
"children": [{
"name": "add",
"value": 593
}, {
"name": "and",
"value": 330
}, {
"name": "average",
"value": 287
}, {
"name": "count",
"value": 277
}, {
"name": "distinct",
"value": 292
}, {
"name": "div",
"value": 595
}, {
"name": "eq",
"value": 594
}, {
"name": "fn",
"value": 460
}, {
"name": "gt",
"value": 603
}, {
"name": "gte",
"value": 625
}, {
"name": "iff",
"value": 748
}, {
"name": "isa",
"value": 461
}, {
"name": "lt",
"value": 597
}, {
"name": "lte",
"value": 619
}, {
"name": "max",
"value": 283
}, {
"name": "min",
"value": 283
}, {
"name": "mod",
"value": 591
}, {
"name": "mul",
"value": 603
}, {
"name": "neq",
"value": 599
}, {
"name": "not",
"value": 386
}, {
"name": "or",
"value": 323
}, {
"name": "orderby",
"value": 307
}, {
"name": "range",
"value": 772
}, {
"name": "select",
"value": 296
}, {
"name": "stddev",
"value": 363
}, {
"name": "sub",
"value": 600
}, {
"name": "sum",
"value": 280
}, {
"name": "update",
"value": 307
}, {
"name": "variance",
"value": 335
}, {
"name": "where",
"value": 299
}, {
"name": "xor",
"value": 354
}, {
"name": "-",
"value": 264
}]
}, {
"name": "Minimum",
"value": 843
}, {
"name": "Not",
"value": 1554
}, {
"name": "Or",
"value": 970
}, {
"name": "Query",
"value": 13896
}, {
"name": "Range",
"value": 1594
}, {
"name": "StringUtil",
"value": 4130
}, {
"name": "Sum",
"value": 791
}, {
"name": "Variable",
"value": 1124
}, {
"name": "Variance",
"value": 1876
}, {
"name": "Xor",
"value": 1101
}]
}, {
"name": "scale",
"children": [{
"name": "IScaleMap",
"value": 2105
}, {
"name": "LinearScale",
"value": 1316
}, {
"name": "LogScale",
"value": 3151
}, {
"name": "OrdinalScale",
"value": 3770
}, {
"name": "QuantileScale",
"value": 2435
}, {
"name": "QuantitativeScale",
"value": 4839
}, {
"name": "RootScale",
"value": 1756
}, {
"name": "Scale",
"value": 4268
}, {
"name": "ScaleType",
"value": 1821
}, {
"name": "TimeScale",
"value": 5833
}]
}, {
"name": "util",
"children": [{
"name": "Arrays",
"value": 8258
}, {
"name": "Colors",
"value": 10001
}, {
"name": "Dates",
"value": 8217
}, {
"name": "Displays",
"value": 12555
}, {
"name": "Filter",
"value": 2324
}, {
"name": "Geometry",
"value": 10993
}, {
"name": "heap",
"children": [{
"name": "FibonacciHeap",
"value": 9354
}, {
"name": "HeapNode",
"value": 1233
}]
}, {
"name": "IEvaluable",
"value": 335
}, {
"name": "IPredicate",
"value": 383
}, {
"name": "IValueProxy",
"value": 874
}, {
"name": "math",
"children": [{
"name": "DenseMatrix",
"value": 3165
}, {
"name": "IMatrix",
"value": 2815
}, {
"name": "SparseMatrix",
"value": 3366
}]
}, {
"name": "Maths",
"value": 17705
}, {
"name": "Orientation",
"value": 1486
}, {
"name": "palette",
"children": [{
"name": "ColorPalette",
"value": 6367
}, {
"name": "Palette",
"value": 1229
}, {
"name": "ShapePalette",
"value": 2059
}, {
"name": "SizePalette",
"value": 2291
}]
}, {
"name": "Property",
"value": 5559
}, {
"name": "Shapes",
"value": 19118
}, {
"name": "Sort",
"value": 6887
}, {
"name": "Stats",
"value": 6557
}, {
"name": "Strings",
"value": 22026
}]
}, {
"name": "vis",
"children": [{
"name": "axis",
"children": [{
"name": "Axes",
"value": 1302
}, {
"name": "Axis",
"value": 24593
}, {
"name": "AxisGridLine",
"value": 652
}, {
"name": "AxisLabel",
"value": 636
}, {
"name": "CartesianAxes",
"value": 6703
}]
}, {
"name": "controls",
"children": [{
"name": "AnchorControl",
"value": 2138
}, {
"name": "ClickControl",
"value": 3824
}, {
"name": "Control",
"value": 1353
}, {
"name": "ControlList",
"value": 4665
}, {
"name": "DragControl",
"value": 2649
}, {
"name": "ExpandControl",
"value": 2832
}, {
"name": "HoverControl",
"value": 4896
}, {
"name": "IControl",
"value": 763
}, {
"name": "PanZoomControl",
"value": 5222
}, {
"name": "SelectionControl",
"value": 7862
}, {
"name": "TooltipControl",
"value": 8435
}]
}, {
"name": "data",
"children": [{
"name": "Data",
"value": 20544
}, {
"name": "DataList",
"value": 19788
}, {
"name": "DataSprite",
"value": 10349
}, {
"name": "EdgeSprite",
"value": 3301
}, {
"name": "NodeSprite",
"value": 19382
}, {
"name": "render",
"children": [{
"name": "ArrowType",
"value": 698
}, {
"name": "EdgeRenderer",
"value": 5569
}, {
"name": "IRenderer",
"value": 353
}, {
"name": "ShapeRenderer",
"value": 2247
}]
}, {
"name": "ScaleBinding",
"value": 11275
}, {
"name": "Tree",
"value": 7147
}, {
"name": "TreeBuilder",
"value": 9930
}]
}, {
"name": "events",
"children": [{
"name": "DataEvent",
"value": 2313
}, {
"name": "SelectionEvent",
"value": 1880
}, {
"name": "TooltipEvent",
"value": 1701
}, {
"name": "VisualizationEvent",
"value": 1117
}]
}, {
"name": "legend",
"children": [{
"name": "Legend",
"value": 20859
}, {
"name": "LegendItem",
"value": 4614
}, {
"name": "LegendRange",
"value": 10530
}]
}, {
"name": "operator",
"children": [{
"name": "distortion",
"children": [{
"name": "BifocalDistortion",
"value": 4461
}, {
"name": "Distortion",
"value": 6314
}, {
"name": "FisheyeDistortion",
"value": 3444
}]
}, {
"name": "encoder",
"children": [{
"name": "ColorEncoder",
"value": 3179
}, {
"name": "Encoder",
"value": 4060
}, {
"name": "PropertyEncoder",
"value": 4138
}, {
"name": "ShapeEncoder",
"value": 1690
}, {
"name": "SizeEncoder",
"value": 1830
}]
}, {
"name": "filter",
"children": [{
"name": "FisheyeTreeFilter",
"value": 5219
}, {
"name": "GraphDistanceFilter",
"value": 3165
}, {
"name": "VisibilityFilter",
"value": 3509
}]
}, {
"name": "IOperator",
"value": 1286
}, {
"name": "label",
"children": [{
"name": "Labeler",
"value": 9956
}, {
"name": "RadialLabeler",
"value": 3899
}, {
"name": "StackedAreaLabeler",
"value": 3202
}]
}, {
"name": "layout",
"children": [{
"name": "AxisLayout",
"value": 6725
}, {
"name": "BundledEdgeRouter",
"value": 3727
}, {
"name": "CircleLayout",
"value": 9317
}, {
"name": "CirclePackingLayout",
"value": 12003
}, {
"name": "DendrogramLayout",
"value": 4853
}, {
"name": "ForceDirectedLayout",
"value": 8411
}, {
"name": "IcicleTreeLayout",
"value": 4864
}, {
"name": "IndentedTreeLayout",
"value": 3174
}, {
"name": "Layout",
"value": 7881
}, {
"name": "NodeLinkTreeLayout",
"value": 12870
}, {
"name": "PieLayout",
"value": 2728
}, {
"name": "RadialTreeLayout",
"value": 12348
}, {
"name": "RandomLayout",
"value": 870
}, {
"name": "StackedAreaLayout",
"value": 9121
}, {
"name": "TreeMapLayout",
"value": 9191
}]
}, {
"name": "Operator",
"value": 2490
}, {
"name": "OperatorList",
"value": 5248
}, {
"name": "OperatorSequence",
"value": 4190
}, {
"name": "OperatorSwitch",
"value": 2581
}, {
"name": "SortOperator",
"value": 2023
}]
}, {
"name": "Visualization",
"value": 16540
}]
}]
};
myChart.hideLoading();
myChart.setOption(option = {
tooltip: {
trigger: ‘item‘,
triggerOn: ‘mousemove‘
},
series: [{
type: ‘tree‘,
data: [json_data],
top: ‘18%‘,
bottom: ‘14%‘,
layout: ‘radial‘,
symbol: ‘emptyCircle‘,
symbolSize: 7,
initialTreeDepth: 3,
animationDurationUpdate: 750
}]
});
}
paintCanvas(‘chart1‘);

或者为你强大的项目画个错综复杂秀破天际的类关系图:


Loading...

▲ 类关系图

function paintCanvas(canvas,data,title=‘‘){var chart=echarts.init(document.getElementById(canvas));chart.setOption({title:{text:title},tooltip:{},legend:{data:[‘‘]},dataZoom:[{id:‘dataZoomX‘,type:‘slider‘,xAxisIndex:[0],filterMode:‘filter‘}],xAxis:{type:‘category‘,data:data.x},yAxis:{scale:true},series:[{name:‘‘,type:‘bar‘,data:data.y}],grid:{top:10}})}
paintCanvas(‘chart2‘,{x:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99],y:[0.009999,0.0099791,0.0099851,0.010045,0.0099323,0.0100227,0.009973,0.0099823,0.0099812,0.0100117,0.0099555,0.0100219,0.0099808,0.0099235,0.0100256,0.0100195,0.0100347,0.0099649,0.0099957,0.0100012,0.0099983,0.0100443,0.0100185,0.0100028,0.0099762,0.0099998,0.010038,0.0099765,0.0100109,0.01005,0.01003,0.0100054,0.0099526,0.010001,0.0100172,0.0100067,0.0099779,0.0100547,0.0100519,0.009982,0.0100288,0.0100559,0.0100406,0.0099738,0.009963,0.0099715,0.0099753,0.0099745,0.0099862,0.0099928,0.0100211,0.009992,0.0100048,0.0099731,0.0100005,0.0100157,0.0100208,0.0099976,0.0099595,0.01004,0.0100246,0.0100253,0.0100169,0.0099769,0.0099607,0.0100206,0.010013,0.0099873,0.0099567,0.0099987,0.0099625,0.0100595,0.0099338,0.0100009,0.0100181,0.0099867,0.0100141,0.010015,0.0099953,0.0100089,0.0100287,0.0100257,0.0100045,0.0100001,0.0100012,0.0100357,0.0099458,0.0100448,0.0099926,0.0099496,0.0100401,0.0099849,0.0099666,0.0100041,0.0100289,0.0099873,0.009978,0.0099922,0.0099923,0.0100045]});

反正在网上写文章这种行为已经没什么节操可言了,为什么不用你脑中那些乱七八糟的JS知识,来让你的文章更骚一点呢?是你吗,秀儿?

本该耀眼的文章,你怎么好意思让它丑陋不堪,寡淡无味,泯然于众?!

The End. \(\Box\)

原文地址:https://www.cnblogs.com/conmajia/p/in-article-js.html

时间: 2024-12-10 22:56:24

反正你们写的都是没有即时演示的教程,我为什么不去看官方文档?的相关文章

Kooboo中怎么写Page Plugin -摘自官方文档

Page plugin development Page plugin is an add-on to Kooboo CMS, and is responsible for making data source available for page access. It is similar to module, but while module contains user interface for both the backend and the frontend site, page pl

写给立志做码农的大学生(蘑菇街你都挂了,你还要面腾讯? 我去,我一定要去)

先简单介绍一下我自己,我是一所普通大学的本科生,大学录取时的专业是非计算机系的,在大一下学期意识到自己喜欢敲代码以后,就提交了转专业申请.大二起开始在计算机系学习.大三时(2015年4月)拿到了腾讯暑期实习的offer,暑期实习的过程中获得留用offer,大四没跑秋招,几乎就在学校浪荡了一年. 我不是大牛,不是来传播鸡汤或成功学的,只是最近有感于学弟学妹们在学习以及规划方面严重不足,觉得这是一个共性问题,遂捉起纸笔,写点东西. 1. 确定方向 1.1 选择比努力更重要 关于方向的选择其实越早确定

如何成为一个优秀的程序员(大部分写的都非常不错)——要勤快,不停的学习;争论是无意义的,不如把两种都学了,会更有收获。

在看这份FAQ之前,你必须先读完ESR的<如何成为一名黑客>(本文末尾附有中译版),该文所讲过的道理我不再重复.该文用很大的篇幅讲什么是黑客文化,虽然态度和信仰的确是成功的最关键因素,但是你肯定会想,做不做黑客跟我没关系,我只是想学个一技之长,找个好工作而已,对吧?那么肯定更希望获得一些具体的可操作的指导.     1.各种软件技术之间是怎样的关系? 我把软件技术分为三个层次:    问题域:计算机图形学.音视频编码.信息安全.模式识别.信息检索.自然语言分析.人工智能.科学计算等:     

Mark一下, dp状态转移方程写对,但是写代码都错,poj 1651 poj 1179

dp题: 1.写状态转移方程; 2.考虑初始化边界,有意义的赋定值,还没计算的赋边界值: 3.怎么写代码自底向上计算最优值 今天做了几个基础dp,全部是dp方程写对但是初始化以及计算写错 先是poj 1651 其实就是个赤裸裸的矩阵连乘,dp方程很容易写出 dp[i][j]=min(dp[i][k]+dp[k+1][j]+r[i]*c[k]*c[j],dp[i][j]); 先贴两个个二逼的代码,mark下自己多么的二逼: 二逼一:在计算的时候使用了还没有算出来的值,模拟下就知道第一重循环里算dp

写给VR手游开发小白的教程:(四)补充篇,详细介绍Unity中相机的投影矩阵

这篇作为上一篇的补充介绍,主要讲Unity里面的投影矩阵的问题: 上篇的链接写给VR手游开发小白的教程:(三)UnityVR插件CardboardSDKForUnity解析(二) 关于Unity中的Camera,圣典里面对每一项属性都做了简要的介绍,没看过的小伙伴传送门在下面 http://www.ceeger.com/Components/class-Camera.html 一.裁剪面 先从这个专业的词汇开始,以下是圣典对裁剪面的介绍: The Near and Far Clip Plane

看别人写的优秀代码,是对自己的一种提高,看别人写的很恶心的代码,对自己也是一种提高:告诉自己不要这样写(转)

这两天,我做了两件事: 1.重构了系统某个模块的部分代码: 花了一天时间,一个6k多行的java文件,搞到4k行加若干个类文件,恕我能力有限,后面的实在重构不下去了,那是一种3个domain属性名几乎一样100多个字段但是却用同一个copy了三遍的方法来处理的欲哭无泪,那是一种使劲滚鼠标滚轮都滚不到一个方法尾部的绝望(100多个字段的几个类属性equals来,equals去,get来,set去的,这样类型的方法有那么五六个,你说能不多吗)...... 2.做了一个日志处理的小工具: 客户要求把日

她去看演唱会了,他去唱K了,他们去开房了.都和我无关...因为我要学习。

寂寞. 一个人早起晚睡不难,但在一群晚起早睡的人中早起晚睡不简单. 没人陪你占座,没人陪你背书,没人陪你写作.学习就是孤独的. 食堂,寝室,教室,你就只能去这三个地方 厕所你都要算好时间再去 没人经常短信你,没人经常鼓励你,没人一直关注你 不管是打雷下雨下雹子还是刀子.都要早起前行去学习,你的伙伴会贪睡不去,但不可以是你. 你的同桌室友饭友学友各种友都可以中途打断他们的计划,你不可以!你要学习 你一个人背着书包跑来跑去,你以为很傻很土很幼稚吗? 别人笑,是羡慕,你笑,是自信. 欲望. 想睡懒觉,

c++函数写的都对,还是说incompatible或者not found的解决办法

vs2010,c++,定义了一个函数如下,在BianHuanYuDib.h文件中: 在BianHuanYuDib.cpp中: 写的完全正确,但还是会报错: 很明显,连std都报错了,一般不是真的有很大错误,我的解决办法是把BianHuanYuDib.h放在include的文件最后: 本来错误的时候是这样的: 修改以后是这样的: 解决(`?ω?′)

跳跳虎-图解+仿写 新手都能学懂的SpringBoot源码课

链接: https://pan.baidu.com/s/1-erJW0GbAZbTuF8jjk3SMQ 提取码: 9b2z 链接: https://pan.baidu.com/s/1g-cA3g3GKal6WwT2On9cmQ 提取码: i4ey 复制这段内容后打开百度网盘手机App,操作更方便哦 全网程序学习资料,包含Java后端.前端.人工智能大数据.Python.数据结构和算法.运维.测试.面试相关等课程,所有视频资料均无加密,普通播放器就可播放,加客服微信coder0416,每天都能免费