7月 13, 2021

First Vue components project

 

vue.Left: template component

.Right: Separated script component



Mapping Component on App.vue, the root component

 

Javascript object array map problem

 for an array of objects, to extract fields and map into a simpler array, 

object : SomeObject = {a: 1, b:2, c:3}

array: SomeObject[] = ...


do:

newArray = array.map(x => ({x.a, x.b}))


instead of

newArray = array.map(x => {x.a, x.b})

 

Otherwise it doesn't work.

 

Reference:

 

"What you need to do is force the parser to treat the object literal as an expression so that it's not treated as a block statement. The trick is to add parentheses around the entire body: "


https://mariusschulz.com/blog/returning-object-literals-from-arrow-functions-in-javascript

7月 11, 2021

Kotlin with gradle

 Some issue faced with after creating new project the first time in Idea for Gradle-Kotlin project.


1. Make sure project root name consistent to package: src/main/kotlin/[packagename]/...

2. main() exist outside class

3. MainClass = [package].MainKt

The suffix Kt is required, or there will be a  'main() not exist in main class' error.