Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用Flexbox布局时,css解析有问题 #79

Open
JohnWong opened this issue Jun 6, 2017 · 0 comments
Open

使用Flexbox布局时,css解析有问题 #79

JohnWong opened this issue Jun 6, 2017 · 0 comments

Comments

@JohnWong
Copy link

JohnWong commented Jun 6, 2017

问题

<View css="{justify-content='space-between'}"></View>

这样的写法,会报错:

space_between isn't a valid key in valid Dic {
    center = 1;
    "flex-end" = 2;
    "flex-start" = 0;
    "space-around" = 4;
    "space-between" = 3;
}

原因

原因是对css的解析不严谨,将css字符串整体将-替换为_,之后对css属性替换回来,值没有替换回来。

elseif (_v.name == "css") then
    _v.value = _gsub(_v.value, "-","_")
    local paramFun = sys:loadstring("return " .. _v.value)
    local t = paramFun()
    local css = ""
    for _k, _v in pairs(t) do
        _k = _gsub(_k, "_","-")
        if (_find(_k, "margin")) then
            css = css .. _k .. ":" .. _v*sys.scale .. ","
        else
            css = css .. _k .. ":" .. _v .. ","
        end
    end

https://github.com/alibaba/LuaViewSDK/blob/master/IOS/luaviewEx/luaviewEx/Assets/kit/pica.lua#L180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant