我正在AMP中构建一个简单的HTML页面,但我遇到了一个问题。我想通过JavaScript更改$username = $_POST['username'];
$password = $_POST['password'];
$creds = array();
$creds['user_login'] = $_POST['username'];
$creds['user_password'] = $_POST['password'];
$creds['remember'] = false;
$user = wp_signon( $creds, false );
if ( is_wp_error($user) )
{
$result['type'] = "error";
$result['message'] = __('Username or password is incorrect', 'rs-theme');
}
else
{
$result['type'] = "success";
$result['message'] = __('Logged in successfully', 'rs-theme');;
}
img
,但似乎无效。
HTML:
src
JavaScript的:
<amp-img id="logo-cat" src="http/images.." alt="logo-category"
这似乎不起作用。
答案 0 :(得分:5)
AMP不支持Javascript。使用amp-bind更新[src]
属性。
<amp-state id="images">
<script type="application/json">
{
"imageUrl_1": "http://via.placeholder.com/350x350",
"imageUrl_2": "http://via.placeholder.com/250x250",
"imageUrl_3": "http://via.placeholder.com/150x150"
}
</script>
</amp-state>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
<button on="tap:AMP.setState({imageUrl: images.imageUrl_1})">Image 1</button>
<button on="tap:AMP.setState({imageUrl: images.imageUrl_2})">Image 2</button>
<button on="tap:AMP.setState({imageUrl: images.imageUrl_3})">Image 3</button>
<amp-img id="amp-img"
src="http://via.placeholder.com/350x350"
layout="responsive"
width="350"
height="350"
[src]="imageUrl ? imageUrl : images.imageUrl_1">
</amp-img>
答案 1 :(得分:0)