6
Groovy中允許做一些字符串的好東西在前端頁面,例如:Groovy的擴展String類
${"hello".capitalize()}
我如何添加一個新的自定義方法將String
類?像:
${"hello".custom()}
Groovy中允許做一些字符串的好東西在前端頁面,例如:Groovy的擴展String類
${"hello".capitalize()}
我如何添加一個新的自定義方法將String
類?像:
${"hello".custom()}
使用的metaClass
String.metaClass.custom = { //dosomething }
見http://www.groovyexamples.org/2010/07/19/dynamically-add-properties-to-a-class/